When I am closing my browser I want a confirmation message.
I am using
window.onbeforeunload = confirmExit;
function confirmExit() {
return "You will Lost this test. Are you sure you want to exit this page?";
}
function confirmExit() {
return "You will Lost this test. Are you sure you want to exit this page?";
}
But this function is also working on page postback on my page.
I want this message on window cclose only
What should I have to do.????


Joginder BangerRank #360 · 7K reputationPosted Nov 10, 2014, 10:57 PM EST
$(window).unload(function() {
var answer = confirm("Are you sure?")
if (answer){
alert("Bye bye!") }
else{ alert("Thanks for sticking around!") }
});
Khargesh RajputRank #616 · 3.9K reputationPosted Nov 10, 2014, 11:04 PM EST
Khargesh RajputRank #616 · 3.9K reputationPosted Nov 20, 2014, 6:06 PM EST
use
OnClientClick="needToConfirm = false;" on controls on page
and
javascript fun is