Using a confirm to prevent someone from closing their firefox window or tab

roscoe
avatar
rank Enthusiast

Enthusiast


Posts: 138
Joined: 2006-03-09

I have an app that will pop up a confirm using the onbeforeunload action if the user tries to close their firefox browser or tab when they haven't saved their data. The problem is that it's not working beause I can't prevent the default action. My code is below and I can't figure out why it doesn't work...

	window.onbeforeunload = function() {
		var value = confirm("Do do this!");
		if (value == false) {
			event.preventDefault();
		}
	}