javascript would fail to create a html element sometimes

Discussion in 'Javascript' started by q2005, Jan 10, 2005.

  1. q2005

    q2005 Guest

    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

    q2005, Jan 10, 2005
    1. Advertisements

  2. q2005

    RobG Guest

    Some code? URL?

    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.
    RobG, Jan 10, 2005
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.