Onbeforeunload Issue
Jul 23, 2005
The onbeforeunload fires just before the current document begins to
unload due to form submission or window closure.
How can I have this code run after window closure (X) but not after
pressing a button (form submission)?
View 2 Replies
ADVERTISEMENT
Jul 23, 2005
Currently I use an onbeforeunload method, to do call various tidy up
methods when a user exits my web application - however I now need to add
additional support, for users migrating to Sun's JVM.
My understanding that the onbeforeunload call is a Microsoft one, and
the net result of having it in a page used by a SUN JVM user is that the
browser does not close.
Does anyone know of an alternative to this method, that is supported
by Sun's JVM?
View 4 Replies
View Related
Nov 29, 2005
I want to override the onbeforeunload event so that when the user
clicks on the close button, at the right top of the screen, it only
open an alert with OK button and don't close the screen ...
View 5 Replies
View Related
Jun 6, 2006
the bug of onbeforeunload is so obvious!
in IE 6 it will popup twice "sometimes"
I am using the following code
window.onbeforeunload = null;
window.onbeforeunload = confirmExit;
var executingPostBack = false;
function confirmExit()
{
if ( typeof executingPostBack != 'undefined' && !executingPostBack)
{
return 'Warning: Modified data has not been saved.' ;
}
}
In some cases, IE pops up it twice, for example, when we click a link
that contains "__doPostBack", onbeforeunload is fired the first time;
when the form is submitted, it is fired second time.
There is no way to work it around, because onbeforeunload is stupid, we
can't know whether the user clicks OK or Cancel.
I would like to use the following code with confirm so that I know
exactly what the user behaves
res = confirm("leaving?");
if (res==1)
{
alert("yes");
}
else
{
alert("no");
}
but I can't use this in onbeforeunload, because I can't stop it!
onbeforeunload always asks for something return, but if I return
anything, it will popup!
View 4 Replies
View Related
Jun 6, 2005
I have written a web application in .ASP with VBScript and JavaScript running against a SQL back end. Everything works great except my BeforeUnload() event:
<%'Add a script to save any unsaved data before the client leaves the page%>
<script language="JavaScript">
window.
function confirmExit()
{if (document.Client_Info_Page.Value_Changed.value == "true")
{if (confirm("This record has been changed. Press [OK] to save; [Cancel] to discard."))
{document.Client_Info_Page.submit();
alert("Changed and save");}
else
{alert("Changed and no save");}
}
}
</script>
<%'END Add a script to save any unsaved data before the client leaves the page%>
This code checks a variable to see if anything's been changed on the page and if it has, it asks the user if they'd like to save before exiting. The alert boxes are just to show the If/Then is working correctly (which it is) but the .Submit() function just gets ignored as the page exits.
Just to play, I made a java button and cut and pasted the submit() into and when that's clicked it submits with no problem.
Anyone know how I can get the onBeforeUnload to push a .Submit()? I've changed it to stop the exit and allow the user to save, but it would be so much smoother if it could be automatic.
View 13 Replies
View Related
Jul 23, 2005
Can 'onbeforeunload' (ie) be used to trigger a javascript? I can't find any info on how or if this is possible.
View 2 Replies
View Related
Feb 9, 2006
Does anyone know how to suppress the default messages?
1. "Are you sure you want to navigate away from this page?"
2. "Press OK to continue, or Cancel to stay on current page"
I need to provide the user a custome message. I tried many approachs, but non of them seem to work. I tried to use a confirm box instead, but for some reason, the return value for onBeforeUnload event seem to be used as string, so return false to the event CANNOT stop the page from refreshing.
View 1 Replies
View Related
Jan 20, 2010
I set some value like in onbeforeUnload
document.getElementById('hGridStateModified').value='YES';
The value is not set and is not available at server side.
(
I set some value like
document.getElementById('hGridStateModified').value='YES';
The value is available at server side.
)
Code
/// START
f(window.body){
window.body.onbeforeunload = saveBeforeExit; // IE else[code].....
View 4 Replies
View Related
Jul 23, 2005
What code can I put in the 'onbeforeunload' event to cancel the 'unload'
action (when user closes browser) and then present the user with an
alert saying that he/she must use the logout button.
View 6 Replies
View Related
Sep 30, 2009
i dont want to show the confirm message when using window.onbeforeunload.Please suggest a solution to hide the confirm message..
View 3 Replies
View Related
May 22, 2009
I'm trying to add the "you have unsaved changes" message to a form. I have it working in every browser except IE7 and IE8.I have set the onbeforeunload with using a global "goodExit" variable (that's supposed to help IE, and it did partially).The thing is, that I have multiple tabs on the page, so I only show part of the form at any given time. If they change a field on one tab, the top of the page shows a visual box of "unsaved data", so that as the users changes tabs the box at the top still shows.The problem is that, IE fires the onbeforeunload anytime someone clicks to change tabs. The only thing that happens when they click a tab is that I use jQuery to show/hide the DIVs appropriately.Why does IE fire onbeforeunload when changing the display of DIVs???!!!No other browser does this.The global "goodExit" variable meant to help IE, seems to work, except that goodExit is set to true if they change any field on a tab, so that then the next tab they switch to fires the event.
View 3 Replies
View Related
Oct 20, 2009
Is it possible to capture the control.event or element.event that was fired to invoke the onbeforeunload event.
For example, if a button is clicked and it causes the onbeforeunload event to fire can i determine which button was clicked.
View 3 Replies
View Related
Aug 16, 2011
On my site I use "window.onbeforeunload" to give a confirmation that the user wants to leave the site when they're doing something which will be interrupted by leaving the site. The problem is that when a user requests a certain file to download, I use "window.location" to point to the PHP script which in-turn starts the file download. Now, the user's browser never actually changes pages, but because I'm launching the download through "window.location" it's triggering the "window.onbeforeunload". Is there any way that I can detect that I'm requesting the download (like matching the script name in the target url?) and then not show the leaving confirmation?
View 2 Replies
View Related
May 10, 2011
I want to run a HIDDEN FUNCTION when I click "OK"...not "CANCEL" in window.onbeforeunload() is it possible?
<script type="text/javascript">
window.onbeforeunload = function()
{
[code]....
View 4 Replies
View Related