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!


9 comments:

Anonymous said...

This really solved my problem, thank you!.

priya said...

call popup window for form submission before window close

Anonymous said...

Hello, its fastidious article regarding media print, we all be aware
of media is a enormous source of facts.

Anonymous said...

I've been surfing on-line more than 3 hours lately, yet I never found any interesting article like yours.
It is lovely value enough for me. Personally, if all website owners
and bloggers made good content as you probably did,
the net will likely be a lot more helpful than ever before.

Anonymous said...

Your style is really unique compared to other folks I've read stuff from.
Thank you for posting when you've got the opportunity, Guess I'll
just bookmark this web site.

Anonymous said...

I like the valuable information you provide
for your articles. I'll bookmark your weblog and check once more here frequently.
I'm rather certain I will be informed many new stuff proper right here!
Best of luck for the following!

Anonymous said...

Thanks for sharing your thoughts about visit this site.
Regards

Anonymous said...

This is a good tip especially to those new to the blogosphere.

Simple but very accurate info? Many thanks for sharing this one.
A must read post!

Anonymous said...

I'm nnot sure why but this website is loading very slow for me.
Is anyone else having thyis issue or is it a issue on my
end? I'll checck back later and see if the priblem still exists.

Powered By Blogger · Designed By Seo Blogger Templates