By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

page exit on windows

P: n/a
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;
}

Sep 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
su******@googlemail.com wrote:
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.
Sep 20 '06 #2

P: n/a
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.
Richard Cornford wrote:
su******@googlemail.com wrote:
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.
Sep 20 '06 #3

P: n/a
su******@googlemail.com wrote:
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.

Sep 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.