Document object is not set in Internet Explorer - works in Firefox

Discussion in 'Javascript' started by jnhemley, Jan 11, 2007.

  1. jnhemley

    jnhemley Guest

    I have a script that works in Firefox but not IE6-

    <script language="JavaScript" type="text/javascript">
    document.Params.ThisPageURL.value=document.URL;
    var x = new Date ();
    document.Params.TimeZoneOffset.value =x.getTimezoneOffset();
    document.Params.submit ();
    </script>

    The form is set this way:
    <FORM ACTION="<?php echo("$Action"); ?>" METHOD="POST" NAME="Params"
    <input type="hidden" NAME="ThisPageURL" value=""><input type="hidden"
    Name="$ERR" value=""><input type="hidden" name ="TimeZoneOffset"
    value=""><input type="hidden" Name="$U" value=""><input type="hidden"
    Name="$R" value=""><input type="hidden" Name="$T" value="">


    I get the following error in IE:
    document.Params.ThisPageURL is null or not an object

    Any idea what the problem is ?
     
    jnhemley, Jan 11, 2007
    #1
    1. Advertisements

  2. ^^
    You need to close the opening form tag there with a '>' character.
     
    Martin Honnen, Jan 11, 2007
    #2
    1. Advertisements

  3. jnhemley

    RobG Guest

    Your script appears to be global code that is executed before the DOM
    object that it refers to is built. Either put the script after the
    element's HTML, or wrap it in a function and execute it after the
    element is created, say use window.onload.

    [...]
    Which is commonly caused by trying to access a DOM object that doesn't
    exist yet.
     
    RobG, Jan 11, 2007
    #3
  4. jnhemley

    jnhemley Guest

    I took out the assignment to ThisPageURL and TimeZoneOffset.value and
    it works fine but I don't know why in both browsers.
     
    jnhemley, Jan 15, 2007
    #4
    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.