Yo-NuTZ
asked on
onbeforeunload event triggered unnecesarily when writing into div with .innerHTML
Hello,
I'm having a problem with the window.onbeforeunload Javascript event. When i add to the page an area where onclick i open up a form (to submit data via ajax) written with div.innerHTML and making it visible through display:block (css property), well then the onbeforeunload event is triggered wrongly (only in Internet Explorer) on writing into a div.
I tried using a guard boolean variable, it didn't work. I tried resetting the onbeforeunload with null and then reassigning, it didn't work (when i say it didn't work it means that the same onbeforeunload event is still triggered when it shouldn't.
Any help in solving this or finding a workaround would ne excellent.
I'm having a problem with the window.onbeforeunload Javascript event. When i add to the page an area where onclick i open up a form (to submit data via ajax) written with div.innerHTML and making it visible through display:block (css property), well then the onbeforeunload event is triggered wrongly (only in Internet Explorer) on writing into a div.
I tried using a guard boolean variable, it didn't work. I tried resetting the onbeforeunload with null and then reassigning, it didn't work (when i say it didn't work it means that the same onbeforeunload event is still triggered when it shouldn't.
Any help in solving this or finding a workaround would ne excellent.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
the # is a placeholder
If the onclick returns false - and note that it will get to the return false ONLY if the function called does not give an error - the href itself is ignored
So only if you have an error in the function, the link to the anchor will be executed...
Michel
A better href than javascript://
is
href="javascript:void(0)"
Michel
If the onclick returns false - and note that it will get to the return false ONLY if the function called does not give an error - the href itself is ignored
So only if you have an error in the function, the link to the anchor will be executed...
Michel
A better href than javascript://
is
href="javascript:void(0)"
Michel
ASKER
i totally forgot, i'm very sorry, here are your points
No problem.
Thanks
Thanks
ASKER
Oh and actually, right now i have <a href="javascript://" onClick="showHide(2); return false"> (# doesn't suit me as it moves the focus of the page to the zone of the anchor or top)