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

Discussion in 'Javascript' started by Mel, Jan 20, 2005.

  1. Mel

    Mel Guest

    example would be awesome

    thanks
     
    Mel, Jan 20, 2005
    #1
    1. Advertising

  2. Re: can UnUnload function be added after the page is displayed, orduring page creation ?

    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/
     
    Martin Honnen, Jan 20, 2005
    #2
    1. Advertising

  3. Mel

    Grant Wagner Guest

    "Mel" <> wrote in message
    news:41efc4ac$...
    > 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 <>
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Grant Wagner, Jan 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    2
    Views:
    2,728
    Steve C. Orr [MVP, MCSD]
    Jul 6, 2004
  2. Bennett Haselton
    Replies:
    1
    Views:
    526
    John M Deal
    Nov 8, 2004
  3. Patrick.O.Ige
    Replies:
    0
    Views:
    779
    Patrick.O.Ige
    Aug 31, 2006
  4. boney
    Replies:
    1
    Views:
    580
  5. Tuxedo
    Replies:
    3
    Views:
    152
    Tuxedo
    Sep 7, 2008
Loading...

Share This Page