page exit on windows

S

suryakul

Hi,
i have the following code
cancelVendorButton' : function(el){
el.onclick = function() {
if (!confirm("Are you sure you wish to leave before saving
changes")){
return false;
}
$('action').value="createScreen";
$('vendorForm').submit();
}
}

THE PROBLEM IS THE FORM IS GETTING SUBMITTED BEFORE THE DISPLAY MESSAGE
EVENT IS EXECUTED..SO WHEN I DO THE CANCEL IN THE EVENT I GET A RUN
TIME ERROR..HOW CAN I PREVENT THIS..IS THERE ANY ALTERNATE WAY TO DO
IT..

i previously used the following code


window.onbeforeunload = displayMessage;
and in my js used

function displayMessage(){
mess="Any Unsaved Changes Will Be Lost"
return mess;
}
 
R

Richard Cornford

i have the following code

cancelVendorButton' : function(el){
el.onclick = function() {
if (!confirm(
"Are you sure you wish to leave before saving changes")){
return false;
}
$('action').value="createScreen";
$('vendorForm').submit();
}
}
<snip>

The above code is not syntactically correct javascript. There is an
apostrophe following the Identifier for the label and an Expression
statement may not start with the - function - keyword, so a
FunctionExpression cannot form the labelled ExpressionStatement. It is
also pointless to be labelling an ExpressionStatement as using a
labelled break or continue statement with the label within one is not
practical.

Richard.
 
S

suryakul

Hi,
I don't get it..is there any way to call the
window.onBeforeUnload at the beginning of the save or cancel.instaed of
submitting the form and then calling it.
 
R

Richard Cornford

Hi,
I don't get it..is there any way to call the
window.onBeforeUnload at the beginning of the save or cancel.
instaed of submitting the form and then calling it.
<snip>

Aubergine.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top