Monday, January 21, 2013

stop a page from exit or unload using jquery

<html>
<head>
<title>Refresh a page in jQuery</title>
 
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
 
</head>
 
<body>
 
<h1>Stop a page from exit with jQuery</h1>
 
<button id="reload">Refresh a Page in jQuery</button>
 
<script type="text/javascript">
 
 $('#reload').click(function() {
 
   location.reload();
 
 });
 
 $(window).bind('beforeunload', function(){
  return 'Are you sure want to leaving?';
 });
 
</script>
 
</body>
</html>

No comments:

Post a Comment