javascript - Use JQuery or onbeforeunload for IE and FF -


i'm working in flex4 application, using javascript, in "index.template.html" document. i'm having issue being able use onbeforeunload firefox. application works in ie, exact same 1 doesn't sit ff. (see below)

<script type="text/javascript"> window.onbeforeunload=before; window.onunload=after;  function before(evt) {    var flex=document.$(application)||window.$(application);    flex.unloadmethod(); //custom method log out user }  function after(evt) {  } </script> 

from i've found, ff doesn't seem register onbeforeunload events, found popular thing use instead binding jquery. so, deleted above code , replaced below code, doesn't display pop-up when user tries leaving page in both ie , ff. seems using jquery seems doing exact same thing, don't know what's going on.

<script type="text/javascript"> $(window).bind("beforeunload",function(event){    return "this should create pop-up"; }); </script> 

eventually nice call "flex.unloadmethod" in first bit of code, time being i'm trying pop-up work know i'm on right track. insight appreciated.

try:

<script>     $(window).on('beforeunload', function(){         return "this should create pop-up";     }); </script> 

example: http://jsfiddle.net/aezta/3/


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -