javascript - Can I override onbeforeunload for a particular element? -


i have page quite bit of work , don't want user able navigate away page (close browser, hit button, etc.) without getting warning. found onbeforeunload event (which think ie-specific, works fine me project uses lots of activex) works great.

problem is, want user able click on little "help" icon in upper-right corner , pop window @ time. causes onbeforeunload fire, though main window never goes anywhere , page never unloads.

the javascript function runs when onbeforeunload event runs puts text event.returnvalue. if ascertain, somehow, icon 1 clicked not put text event.returnvalue in situation. how have page figure out?

let me guess: "icon" link javascript: url? change real button, real link, or @ least put functionality in onclick event handler (that prevents default behavior). problem solved.

<!-- clicking link nothing. no onbeforeunload handler triggered.  nothing.  , put in before return false bit... ...and onunload handler still not called... --> <a href="http://www.google.com/" onclick="return false;">blah1</a> <!-- should nothing, ie trigger onbeforeunload  handler --> <a href="javascript:void(0)">blah2</a> 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -