<script language="javascript" type="text/javascript"> var isClose = false; //this code will handle the F5 or Ctrl+F5 key //need to handle more cases like ctrl+R whose codes are not listed here document.onkeydown = checkKeycode function checkKeycode(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; if (keycode == 116) { isClose = true; } } function somefunction() { isClose = true; }
beforeunload
beforeunload | onbeforeunload event[^] Close the current window.Navigate to another location by entering a new address or selecting a Favorite.Click an anchor that refers to another document.Invoke the anchor.click method.Invoke the document.write method.Invoke the document.close method.Invoke the window.close method.Invoke the window.navigate or NavigateAndFind method.Invoke the location.replace method.Invoke the location.reload method.Specify a new value for the location.href property.Submit a form to the address specified in the ACTION attribute via the INPUT type=submit control, or invoke the form.submit method.Invoke the window.open method, providing the possible value _self for the window name.Invoke the document.open method.Click the Back, Forward, Refresh, or Home button.
anchor.click
document.write
document.close
window.close
window.navigate
NavigateAndFind
location.replace
location.reload
location.href
ACTION
INPUT type=submit
form.submit
window.open
_self
document.open
Quote:The beforeunload event is fired when the window, the document and its resources are about to be unloaded.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)