I’m using the jQuery code below to launch an overlay div and it works great in Chrome and Firefox — but in IE9 it launches a window “Do you want to leave this page?” and also says “message from web page: null”. The window continues to come up on every single link clicked on after that until you end the session by logging out (it’s a Codeigniter based app)
Any insight as to what may be causing this would be much appreciated.
EDIT: Offending code is:
window.onbeforeunload = function() { saveFormData(); return false; }
I don’t know where the exact issue in your page is but I believe you’ve encountered the Joys of
IEand theonbeforeunloadevent.In Internet Explorer it treats all navigation link clicks as to be “leaving” the page and thus if you have an onbeforeunload event defined you will get the confirmation message (presuming your code, or the CodeIgnitor framework has attached a handler)
The problem is that a link like this:
will trigger IE to believe the user is leaving the page.
The way I got around this was to do the following (ugly but it worked).
In my small page (a popup window) on the 4-5 links that were “internal” to the page I added a CSS class:
class="internal"then in myonbeforeunloadevent I would check to see if the source element that triggered the event had the class set… and if so “ignore” throwing up my “Are you sure you want to leave?” type warning…However on a “main” page with litterally 100’s and 100’s of links this would be very ugly to try and implement. – Best of luck.