Reputation: 19
I am looking at this code and as I'm new to web design I'm unable to understand it.
So on my index page I have a link to google and the ext.js
page the following code.
This is what I understand which is wrong.
The user clicks ok
or cancel
, therefore the variable c
is either ok
or cancel
. Now I don't see the point of the if
statement, because it will be either ok
or cancel
on other words true or false.
$(window).unload(function(){
var c = confirm('Are you sure you want to leave?');
if(c){
return true;
}else{
return false;
}
});
Upvotes: 0
Views: 89
Reputation: 944564
the variable c is either ok or cancel
No, it will be true
or false
depending on which of OK or Cancel (or whatever the local i18ned version is for the browser in question) was pressed.
i dont seee the point of the if statement
There isn't a point to it.
return confirm('Are you sure you want to leave?');
… gives the same result, much more concisely.
Upvotes: 10