Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > can UnUnload function be added after the page is displayed, or during page creation ?

Reply
Thread Tools

can UnUnload function be added after the page is displayed, or during page creation ?

 
 
Mel
Guest
Posts: n/a
 
      01-20-2005
example would be awesome

thanks


 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-20-2005


Mel wrote:
[Unload]

You can set
window.onunload = function (evt) {

};
with script at any time during page creation or after the page is displayed.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      01-20-2005
"Mel" <(E-Mail Removed)> wrote in message
news:41efc4ac$(E-Mail Removed)...
> example would be awesome


<body>
<button onclick="
window.onunload = function()
{
alert('Leaving...');
}
">Click this</button>
<a href="http://www.yahoo.com">Then click this</a>
</body>

Works in Firefox 1.0 and Opera 7.54u1
Does not work in IE 6.0.2900

I believe it does not work in IE because IE tears the page down
(including any script embedded in the page) when you _start_ to navigate
away from the page. Oddly enough, the next example works in IE, I'm sure
there's a perfectly logical explanation for this behaviour (probably has
something to do with when the delegate is bound to the event), but I'm
not going to waste my time thinking about it.

<body onunload="placeholder();">
<script type="text/javascript">
function placeholder() { }
</script>
<button onclick="
window.placeholder = function()
{
alert('Leaving...');
}
">Click this</button>
<a href="http://www.yahoo.com">Then click this</a>
</body>

--
Grant Wagner <(E-Mail Removed)>
comp.lang.javascript FAQ - http://jibbering.com/faq


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Q: Create unUnload event trigger outside body tag? Tuxedo Javascript 3 09-07-2008 01:17 PM
Solution for posterity: GridView, Datakeys, and "Item has already been added. Key in dictionary: 'CategoryID' Key being added: 'CategoryID'" ASP .Net 2 11-02-2006 04:48 AM
Prevent error on bad email address during user creation on wizard asp.net 2.0 Smokey Grindle ASP .Net 0 07-19-2006 07:04 PM
How to (batch) set EXIF date taken and IPTC creation date and creation time for photos with filenames YYMMDDHHMMSS#.jpg? guercheLE@gmail.com Digital Photography 1 10-04-2005 07:15 PM
how come user control added to page doesn't get added to codebehind file? Bennett Haselton ASP .Net 1 11-08-2004 09:26 PM



Advertisments