About the author

Vijay Kodali
E-mail me Send mail

Site Statistics

Site Meter

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Detecting Asp.Net page close event

Sometimes we have to capture page close event or navigation event to alert users. For example, Alerting user for navigating away from input page without saving it. Check this java script code..

window.onbeforeunload= function(){
if((window.event.clientX<0) || (window.event.clientY<0))
    {
      event.returnValue = "Are you sure you want to navigate away from this page? You haven't saved this form.";
    }
};

This code works only in Ie6/7. And also keep in mind, we can never catch the browser close event for 100%. For example, what if the user kills the browser process or shut down OS.


Tags:
Posted by vijay on Thursday, March 20, 2008 2:49 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Comments

credito facil United States

Monday, August 30, 2010 7:01 PM

credito facil

Great Post, Exactly what i was looking for. i'm bookmarking. thanks for sharing. regards.

military style jacket United States

Thursday, September 02, 2010 4:18 PM

military style jacket

This was exactly the type of information i've been searching for.  Your technical expertise is exactly what I needed in trouble shooting a few issues.  I'll continue perusing your blog and hope that you continue to write such useful post.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading