Click here to Skip to main content
15,921,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a scnario where I need to display a confirmation div to users of my website whenever they closes the browser window.

I have found the code to show confirmation message in javascript Confirmation message (using onbeforeunload), but I need to display message in div.

Also please suggest me whether it's possible or not.

Thanks
Ashish
Posted

On the 'onbeforeunload' javascript event, call the javascript function which will show/display the div to the user. It will work for sure
 
Share this answer
 
v2
give your div a id such as "kas" then write this code in java script


XML
<script type="text/javascript">
    window.onbeforeunload = function() 
{ 
   document.getElementById('kas').style.visibility = 'visible';
}
</script>


but keep in mind that you will not be able to see that div becouse page will close itself right after displaying that div until you diplays any alert box or stops page from unloading
 
Share this answer
 
v2
Comments
bbirajdar 3-Feb-12 8:26am    
Exactly Mr Atiq.. So the div displayed must be a modal.. Best way a alert or confirm dialog from javascript should be used instead of a div......My +4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900