Navigate Away Page Alert


Hi Friends,

Have you ever seen this message on webpages,

“Are you sure you want to navigate away from this page?
Press OK to continue, or Cancel to stay on the current page.”

The best example to see this message is when you are composing a email in Gmail and then when you try to close Gmail without sending or saving email, Gmail will prompt this message.

You can use this message on your webpage where you doing some process in backend, it may be an AJAX request as well.

So to implement this, Javascript as already a built in function, may be most of us don’t know about this

window.onbeforeunload = function() { return "Are you sure you want to leave?"; }

Try this!

cheers,
JT

Advertisements

One thought on “Navigate Away Page Alert

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s