onbeforeunload dilemma: iframe breaking vs. annoying message on refresh/back buttons click
Posted
by Tossapol
on Stack Overflow
See other posts from Stack Overflow
or by Tossapol
Published on 2010-03-10T08:06:15Z
Indexed on
2010/05/26
10:21 UTC
Read the original article
Hit count: 213
I'm implementing a search service called SearchInsideOut. http://bit.ly/97SFyW
This search service simply replaces web page results by full web pages (Yes, I used iframe
).
The problem I have to deal with is iframe-breaking pages.
The promising solution I found is using onbeforeunload
to let users decide whether to stay or leave my site.
But this also creates another annoying behavior.
When users click other links in my site, onbeforeunload
will also be triggered.
Fortunately, I could solve this case by placing window.onbeforeunload=null
in the onclick event of those links of my site.
Unfortunately, I have no idea how to detect external events like clicking "refresh/back" buttons.
What should I do to solve this difficulty?
All suggestions and comments are highly appreciated.
© Stack Overflow or respective owner