Solved

Internet Explorer closing event -catching  in JavaScript

Posted on 2007-11-21
4
1,106 Views
Last Modified: 2008-02-01
Is there a way of catching a form_unload a type of event for Internet Explorer, with a cancel= true type of parameter?
I mean when  a form/IE is exiting without saving, it gives you a chance to ask the user to confirm " Exit without saving?"
0
Comment
Question by:Silas2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20326934
window.onclose?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20327095
Nope. onClose does not exist.


You are looking for
<body onBeforeUnload="returnValue='Please don\'t go'">
0
 
LVL 4

Assisted Solution

by:rallsaldo
rallsaldo earned 60 total points
ID: 20328323
Hi,

I think the onBeforeUnload event will also fire if the user navigates away from the page, i.e. clicks a link. I have used the following to get round this in javascript (cut down version of actual):


var windowclose = false;
 
function ConfirmClose()
{
     
  if (event.clientY < 0)
   { 
     //I make an AJAX call to another page in here
     event.returnValue = 'Your message';
     
     windowclose=true;
   }
}
 
window.onbeforeunload = ConfirmClose;

Open in new window

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 65 total points
ID: 20328476
That will indeed work on some versions and for an unknown period...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
innerHTML 7 34
Html form and modal / img src -problem 3 29
How to deal with the query string 8 37
How to control cache of some js files ? 7 39
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question