Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As anyways your <code>onbeforeunload</code> is interpreted through JS, you probably can use a boolean flag in a global variable to know whether it's the first time the process started by the event runs. Like:</p> <pre><code>&lt;head&gt; ... &lt;script ...&gt; var flag=true; var ret=""; function getoff() { if(flag) { //do your things and save your return value to the global variable "ret" //ret="Unsaved changes"; flag=false; //with this, the code above will be executed only once } return ret; //the second call will return the same thing as the first call, as first call's return value is stored in a global variable, and is not modified during the second call } &lt;/script&gt; &lt;/head&gt; &lt;body onbeforeunload="return getoff();"&gt; ... </code></pre> <p>Another possibility perhaps, as according to <a href="https://stackoverflow.com/q/6917074/1269732">this post</a> the problem seems to come from changing the page using JS, you can use a hidden hyperlink to change the page using HTML, something like:</p> <pre><code>&lt;a href="404.htm" id="myButton" style="display:none;visibility:hidden;"&gt;&lt;/a&gt; </code></pre> <p>Then your button could do:</p> <pre><code>&lt;input type="button" ... onclick="document.getElementById('myButton').click();"&gt; </code></pre> <p>Assuming any of this works, a hidden link like that is an ugly hack (the first possibility isn't much prettier anyway), but what doesn't require some ugly hacks when it's about having MSIE behave like if it was a web browser...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload