Wednesday, September 29, 2010

call function in javascript before window close

if you want to ask user before closing popup window or you want to perform certain operation before window gets closed, you can use below code for that:

window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
if (evt) {
evt.returnValue = message;
return message;

Solution by:Rajesh Rolen

Share This!


Anonymous said...

This really solved my problem, thank you!.

priya said...

call popup window for form submission before window close

Powered By Blogger · Designed By Seo Blogger Templates