A day with .Net

My day to day experince in .net

Are you sure you want to navigate away from this page?

Posted by vivekcek on March 10, 2012

Do you want a message to show when the user try to close tab or leave your page like facebook.Just include this script in your page.

<script type="text/javascript">
window.onbeforeunload = function (event) {
var message = 'All changes will get lost!';
if (typeof event == 'undefined') {
event = window.event;
if (event) {
event.returnValue = message;
return message;


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s