OnBeforeUnload And Submit() Together?

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


ADVERTISEMENT

OnBeforeUnload Alternative

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

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 View Related

Override Onbeforeunload

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

Any Alternate For OnBeforeUnload?

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

Can 'onbeforeunload' (ie) Be Used To Trigger A Javascript

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

Overriding OnBeforeUnload Dialog Message

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

Onbeforeunload Not Setting Data Values?

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

Cancel The 'unload' Action In 'onbeforeunload' Event

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

Avoid Confirm Message When Using Window.onbeforeunload

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

Show/Hide Divs Trigger OnBeforeUnload (IE)?

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

Capture Event That Was Just Fired In Onbeforeunload Event

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

Get Target Url From "window.onbeforeunload"?

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

Possible To Trigger An "action" When You Click "OK" In Window.onbeforeunload?

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

Submit(); Wont Submit - How To Make It Submit

Jan 26, 2011

This is the code

Code:

<script>
function autoUpdate() {
var text = document.documentElement.innerHTML;
var url = "http://192.168.0.2/user/edit/account" + myAccountNumber + "/edit";

[code]....

View 7 Replies View Related

3 Submit Buttons - Stop Or Continue Form Execution With A Confirm Box On The Third Submit Button ?

Apr 23, 2009

On my form I have 3 submit buttons which handle different things.I am looking for a way to stop or continue form execution with a confirm box on the third submit button and the third only.I can't use onsubmit because that will trigger on all three buttons.

View 2 Replies View Related

JQuery :: Load Data From Submit Tags (multiple Submit Buttons)?

Apr 9, 2011

If I disable JS is running everything as I need. (but it isn't my objective)

<form id='RequestData' action='request.php' method='post'>
<button type='submit' name='par[1]' value='V1'>
<button type='submit' name='par[2]' value='V2'>

[code]....

Script work, but send wrong data, always send to request par[3]='V9' how I can do to send data' from buttons which I click ?

Myobjective it data:

par => array(
[1] => 'V1'
)

only one value of array PAR

View 2 Replies View Related

JQuery :: Submit And Reloading Form Values After Submit Button Is Clicked?

Jul 13, 2011

In the following .submit function, I am attempting to grab the value of the selected option in the facilityCodes dropdown list when I click the submit button and then during the submit function,select the facilityCode again in the dropdown list when the page reloads and then disable the list so that the user cannot change it.However,the situation is when I reload the page after the submit button is clicked the dropdown defaults to the first option and the list is enabled.I apparently am not understanding how.submit works so that I'm selecting the option I'm defining in my code below and then disabling the list AFTER the page reloads due to an error on the page. My question is how can I accomplish this?Here is my code:

$(function() {
$("#ARTransferForm").submit(function() {
var msgsCount = 0;[code]....

View 1 Replies View Related

Press Return In Text Box Doesn't Submit Nor Warning Box - But When Click Submit It Ok?

Aug 7, 2009

I have a form that when you click submit gives a warning box asking if to continue code below Now when I type in the text field and press enter it doesn't submit nor does it pop up the warning box, how would I do this

Code for submit button
<script LANGUAGE="JavaScript">
<!--
function submitMyForm()
{
var agree=confirm("ARE YOU SURE ?");

[Code]...

View 2 Replies View Related

Submit The Form Data To The Popup Window Without A Submit Button

Jul 23, 2005

The following will submit the form data to popup by clicking the submit button. I want it will submit the form automatically to the popup, there is no submit button in this page. Basically this page should not show up.

<script type="text/javascript">
function submitmyform(f) {
f.target = 'foo'
window.open('',f.target,'menubar=no,scrollbars=no, width=800,height=800');
f.submit();
return false;
}
</script>

<form name="myform" action="popup.asp" target="_blank" method="post"
onsubmit="return submitmyform(this);">
<input type="hidden" name="item" value="item"/>
<input type="submit" value="submit to popup"/>
</form>

View 2 Replies View Related

JQuery :: Submit Form Using Text Link Rather Than Submit Button?

Sep 28, 2010

I'm using mailchimps signup box (they don't have a decent forum to ask on) on my website and want to adjust the submit button and change it to a normal link. Here's the button that submit's the form:

[Code]...

View 14 Replies View Related

JQuery :: Prevent Default Submit In Dom And Replace With Submit And Onclick?

Apr 20, 2011

I have a DOM loaded from a remote site, i cannot alter that page. The DOM has a input:submit in the form that looks something like this:

<FORM NAME="frm1" METHOD="POST" ACTION="ServletController;jsessionid=72CDF83C126FFF9D87821CE9E9B9E860.fre01" onSubmit="return checkFormSubmit();">
<input type="hidden" name="mode" value="apply">
<input type="submit" name="Apply" value="Apply" onClick="return applyClicked();">
</FORM>

I need to replace the default ACTION with an ajax post with the current form data, but I also need to keep the:onClick="return applyClicked(); here is what works, however I cannot get the return applyClicked() to prevent the submit if it is false.

[Code]...

View 2 Replies View Related

JQuery :: Disable Submit Button On Form Submit?

Jan 31, 2008

I have a page with many forms that I need to change from a post to an ajax call. That part is working, no problem, but now I want to disable the submit button while it's waiting on the server response and then re-enable it when the response comes back.

Here's what I have:

$(function() {
$('form').each(function() {
$(this).submit(function(){

[code]...

I can't figure out what my selector should be to get the submit button of the form that's being submitted. What should I be using instead? Also, if the call errors out, I'd like to just post the form as usual.

View 12 Replies View Related

Check Which Submit Buttand Then Confirm Submit Form?

Sep 25, 2009

I have a php form and it has 3 submit buttons namely "delete" , "update_quantity" and "place_order".They all work fine but I want to build in a check for each one just in case the user click one of the buttons by mistake.So Each one must have a different message like for delete it must be, "Are you sure you want to delete Record nr ......" OK or Cancle.
And for update " Are you sure you want to update Quantity to....." OK or Cancle.

View 2 Replies View Related

Disable/reenable Form Submit With No Submit Button?

Jul 5, 2010

I have a form without a submit button. It gets submitted programmatically with document.form.submit().

What I need is to be able to disable this form's submit capability on page load and then reenable it at some later point. Remember there is no 'input' button element.

Code:
What I've tried so far is like this:
savedSubmit = document.inputs.submit;
document.inputs.submit = None;
then later:
document.inputs.submit = savedSubmit;

but this does not work. How can I do this?

View 4 Replies View Related

Javascript Submit Problem : Form Won't Submit

Jul 23, 2005

So, here's my problem :

I've created a table in my document, presenting a list of items, one
can 'select' by clicking on it... (Kinda like a menu, you make your
choice from) But since this table can get very long, I've put
something of a 'search-form' on top, which enables the user to make a
selection of products from the list.

Now, the form uses a "post" method, and submits to itself, using the
form action. Some PHP script will make sure that the form is filled
out already, the next time it's presented.

The table, containing a list of products is presented, below the form.
When a user clicks on a product, the product should be "selected". At
first i just used a <a href="zoeken.php?prod_id=24"> link to do this,
but the problem is that my form won't remain in tact.

So now, the global idea is to submit the form after setting a hidden
form-field using JavaScript, using a onClick event.

Here's my code :

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved