javascript would fail to create a html element sometimes

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

    javascript would fail to create a html element sometimes

    Hi, all

    I have a very simple page and on the page there is a small javascript to
    create a html element. On one of my PC's runs no problem, the page is
    displayed and the created element is there. While on the other of my PC's
    (3) the javascript won't create the HTML element. I used an alert() just
    before it creates the element and I found the difference. On the right PC,
    when alert() prompted the page was already half done on the screen. On the
    others, when alert() prompted there was nothing about the page displayed on
    the screen. How do I set the IE to display and run javascript at the same
    time, just like the right PC? thank you very much!

    OS win xp
    IE v6.0

    Jack


  • RobG

    #2
    Re: javascript would fail to create a html element sometimes

    q2005 wrote:[color=blue]
    > Hi, all
    >
    > I have a very simple page and on the page there is a small javascript to
    > create a html element. On one of my PC's runs no problem, the page is[/color]

    Some code? URL?

    [...][color=blue]
    > before it creates the element and I found the difference. On the right PC,
    > when alert() prompted the page was already half done on the screen. On the
    > others, when alert() prompted there was nothing about the page displayed on
    > the screen. How do I set the IE to display and run javascript at the same
    > time, just like the right PC? thank you very much![/color]

    Sounds like your JS refers to something in the HTML that hasn't been
    created by the time your JS runs - is the script before the element it
    modifies? The content of your page is executed as the browser reads
    it, it doesn't wait until everything is loaded.

    Either fire your script from an onload= or move it lower down the page.

    --
    Rob

    Comment

    Working...