开发者

html JavaScript onunload

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 la开发者_Go百科nguage.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜