Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- clicking this link will do nothing. No onbeforeunload handler triggered.
- Nothing.
- And you could put something in before the return false bit...
- ...and the onunload handler would still not get called... -->
- <a href="http://www.google.com/" onclick="return false;">blah1</a>
- <!-- this should also do nothing, but IE will trigger the onbeforeunload
- handler -->
- <a href="javascript:void(0)">blah2</a>
- Page.ClientScript.RegisterStartupScript(typeof(String), "ConfirmClose", @" <script> window.onbeforeunload = confirmExit; function confirmExit() { if(postback == false) return ""Please don't leave this page without clicking the 'Save Changes' or 'Discard Changes' buttons.""; } </script>");
- OnClientClick="postback=true;return true;
- <html>
- <head>
- <script language="Javascript" type="text/javascript">
- window.onbeforeunload = exitCheck;
- window.onunload = onCloseDoSomething;
- function onCloseDoSomething()
- {
- alert("This is executed at unload");
- }
- function exitCheck(evt)
- {
- return "Any string here."}
- </script>
- </head>
- <frameset rows="100%">
- <FRAME name="main" src="http://www.yourDomain.com/yourActualPage.aspx">
- </frameset>
- <body>
- </body>
- </html>
Add Comment
Please, Sign In to add comment