0

I am using the JavaScript method onunload, but this is triggered when the page is close or navigated to another page or the back button is hit. Is there a way to differentiate between page closing and the back button being hit? I am using a combination of html JavaScript and PHP as the server side language.

2 Answers 2

2

As far as I know there is no way to differentiate between these. If you use onbeforeunload as Gidon suggested, you can at least offer the user the choice whether he wants to stay on the current page or really leave and possibly lose data.

UPDATE: if you are playing around with iframes, it might be possible (though not surely cross-browser), found it here: http://www.tek-tips.com/viewthread.cfm?qid=1590281&page=25

Sign up to request clarification or add additional context in comments.

Comments

0

https://developer.mozilla.org/en/DOM/window.onbeforeunload

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.