internet explorer - Why IE10 fires beforeunload event when clicking on anchor element with javascript href and how to prevent it -



internet explorer - Why IE10 fires beforeunload event when clicking on anchor element with javascript href and how to prevent it -

in order track when user leaves page, hear beforeunload event. works fine until user, uses ie10, clicks on empty link (anchor) javascript in href parameter instead of url. example:

<a href="javascript:void(0)">empty link js in href</a>

this case makes ie10 sometimes fire beforeunload event. chrome/ie11 work fine (0 beforeunloads), while ie10 fires time time, if click fast. here jsfiddle seek it. know why happen , how prepare it? happy remove/replace such anchors in mark-up, impossible in case. thanks.

technically, ie10 may considered right because are unloading page... kind of. if link were:

<a href="javascript:'blah';">

then end on new page content 'blah'. how javascript: links work. void returns nil (undefined), , when javascript: link returns nil not replace page contents.

a similar thing happen, in theory, if target resource download - page unloaded because target download, page not change. , http response of 204 no content should trigger behaviour.

however, have noticed, undesirable behaviour , has become more mutual see browser not trigger unload event until page beingness unloaded. unfortunately, browser-level thing , outside control, far i'm aware.

to knowledge real prepare ensure preventdefaulting click event.

javascript internet-explorer anchor internet-explorer-10 onbeforeunload

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -