DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Matthew Solnit Guest

    onbeforeunload event and javascript protocol

    <a href='javascript: window.alert("hello world!");'>Click here</a>


    In IE 5.5, clicking this link will cause the window.onbeforeunload() event to
    fire. Is this a bug? Is there any workaround?

    According to MSDN, the onbeforeunload event should fire only if the <A> "refers
    the browser to another Web page".

    -- Matthew Solnit



  2. #2
    Stuart Guest

    Re: onbeforeunload event and javascript protocol


    Matthew,
    it seems like it is an error but it is m$ after all!

    The following code will execute the javascript statement and the onBeforeUnLoad
    event won't be fired.

    <a href="nowhere.html" onClick="JavaScript:window.alert('hello world!');return
    false;">Click here</a>

    Let me know if this isn't what you are after.

    Stu.

    "Matthew Solnit" <msolnit@nospam.yahoo-com> wrote:
    ><a href='javascript: window.alert("hello world!");'>Click here</a>
    >
    >
    >In IE 5.5, clicking this link will cause the window.onbeforeunload() event

    to
    >fire. Is this a bug? Is there any workaround?
    >
    >According to MSDN, the onbeforeunload event should fire only if the <A>

    "refers
    >the browser to another Web page".
    >
    >-- Matthew Solnit
    >
    >



  3. #3
    Matthew Solnit Guest

    Re: onbeforeunload event and javascript protocol

    "Stuart" <stuartv@prologic.com.au> wrote in message
    news:3b562f12$1@news.devx.com...
    > The following code will execute the javascript statement and the

    onBeforeUnLoad
    > event won't be fired.
    >
    > <a href="nowhere.html" onClick="JavaScript:window.alert('hello world!');return
    > false;">Click here</a>


    Thanks for your reply. We have been doing something very similar. The only
    difference is that we use href="#" instead, so that the status bar does not show
    a fake URL during a mouseover.

    Just out of curiousity, do you know if other browsers behave as expected?

    -- Matthew Solnit



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links