[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Internet Explorer closing event -catching  in JavaScript

Posted on 2007-11-21
4
Medium Priority
?
1,110 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 240 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 260 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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

649 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