history.back() works for IE, I believe.
but the problem here is that if the user is leaving the page by going to any other page, forward in the site, some other site altogether, or whatever, window.unload() will run, and it will send them back a page. how are you preventing that?
history.back() is the equivalent of history.go(-1)
I'm doing history.go(0) which keeps you where you are. works in Mozilla, not in IE.
you're only prevented if hasChanged == 1, and also, I have a confirmation dialog, that I removed for clarity, so you can leave if you really want to.
oh yeah.. i fooled myself with the 0/-1 thing.
do you really have to prevent them from hitt Back? It would be a lot easier if you just checked hasDirty() when clicking on any submit buttons or UI links.
back isn't important, I need a way of preventing them from leaving the page when they:
1) click any link in the page
2) click any button in the page (except the save changes button, which will clear the dirty flag)
How would I do this? I can't add onClick()'s to every link in the page, because some of them are from an included page that has navigation links, and is used on pages where there is no dirty flag.
Say you're on page 2, and you click a link, and the hasDirty flag is set. if I used history.back(), I'd be sent to page 1. I want to stay on page 2.