javascript: void(0) problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • buhailiang

    javascript: void(0) problem

    I've a 'TEST' link on page, which has href='javascrip t: void(0)', and
    a big iframe page.
    When I load the page, window.onload event is triggered after the big
    iframe page loaded,
    If I click the 'TEST' link before the window.onload execute, the
    window.onload will never execute in IE 6.0.


    <html>
    <body>
    <a href='javascrip t: void(0)'>TEST</a>
    <div id='tt'></div>
    <iframe src='http://www.yahoo.com'> </iframe>
    <script>
    window.onload = function(){
    document.getEle mentById('tt'). innerHTML = '1';
    }
    </script>
    </body>
    </html>

  • Randy Webb

    #2
    Re: javascript: void(0) problem

    buhailiang said the following on 4/16/2007 10:22 PM:
    I've a 'TEST' link on page, which has href='javascrip t: void(0)', and
    a big iframe page.
    When I load the page, window.onload event is triggered after the big
    iframe page loaded,
    If I click the 'TEST' link before the window.onload execute, the
    window.onload will never execute in IE 6.0.
    Yet another reason not to use a javascript: URL
    <URL:http://jibbering.com/faq/index.html#FAQ4 _24>

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Evertjan.

      #3
      Re: javascript: void(0) problem

      Randy Webb wrote on 17 apr 2007 in comp.lang.javas cript:
      buhailiang said the following on 4/16/2007 10:22 PM:
      >I've a 'TEST' link on page, which has href='javascrip t: void(0)', and
      >a big iframe page.
      >When I load the page, window.onload event is triggered after the big
      >iframe page loaded,
      >If I click the 'TEST' link before the window.onload execute, the
      >window.onloa d will never execute in IE 6.0.
      >
      Yet another reason not to use a javascript: URL
      <URL:http://jibbering.com/faq/index.html#FAQ4 _24>
      >
      Right you are, Randy, but what is the problem of the OP?

      If he/she does not like the behavour, why put in that link?

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Randy Webb

        #4
        Re: javascript: void(0) problem

        Evertjan. said the following on 4/17/2007 3:58 AM:
        Randy Webb wrote on 17 apr 2007 in comp.lang.javas cript:
        >
        >buhailiang said the following on 4/16/2007 10:22 PM:
        >>I've a 'TEST' link on page, which has href='javascrip t: void(0)', and
        >>a big iframe page.
        >>When I load the page, window.onload event is triggered after the big
        >>iframe page loaded,
        >>If I click the 'TEST' link before the window.onload execute, the
        >>window.onlo ad will never execute in IE 6.0.
        >Yet another reason not to use a javascript: URL
        ><URL:http://jibbering.com/faq/index.html#FAQ4 _24>
        >>
        >
        Right you are, Randy, but what is the problem of the OP?
        The problem of the OP is that they are clicking on a link before the
        page has finished loading so the onload event never fires. It will do
        that with *any* link if there is nothing in the link to tell the browser
        not to navigate. The only reason the OP is seeing the behavior and
        doesn't see it with a "normal" link is that a normal link causes the
        browser to navigate away so you don't realize the onload event never fired.
        If he/she does not like the behavour, why put in that link?
        Precisely.

        --
        Randy
        Chance Favors The Prepared Mind
        comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
        Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

        Comment

        Working...