Firefox and getElementById

Discussion in 'Javascript' started by Hartmut J?ger, Nov 27, 2004.

  1. Hi there,

    I defined a div in the HTML body like this one:

    <div id="santa" style="position: absolute; top: 400px; left: 700px;">
    <img src="grafiken/xmasani.gif" width="96" height="72" border="0">
    </div>

    When I refer in JavaScript to this <div> with:

    document.getElementById["santa"].style.pixelTop = docheight-72;

    I always get the error message "document.getElementById.santa has no
    properties" in Firefox 1.0 JavaScript Console.

    Where is the point of my mistake?

    I want to move a GIF-Animation on the document window. In IE6 all runs
    well.

    Thanks for help. Hartmut
     
    Hartmut J?ger, Nov 27, 2004
    #1
    1. Advertising

  2. Hartmut J?ger

    Mick White Guest

    Hartmut J?ger wrote:

    >
    > document.getElementById["santa"].style.pixelTop = docheight-72;


    document.getElementById("santa").style.pixelTop = docheight-72;

    Mick
     
    Mick White, Nov 27, 2004
    #2
    1. Advertising

  3. Hartmut J?ger wrote:


    > I defined a div in the HTML body like this one:
    >
    > <div id="santa" style="position: absolute; top: 400px; left: 700px;">
    > <img src="grafiken/xmasani.gif" width="96" height="72" border="0">
    > </div>
    >
    > When I refer in JavaScript to this <div> with:
    >
    > document.getElementById["santa"].style.pixelTop = docheight-72;


    That is a function you need to call with () e.g.
    document.getElementById("santa")
    Also pixelTop is not a property defined in CSS so use
    document.getElementById("santa").style.top = (docheight-72) + 'px';




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Nov 27, 2004
    #3
  4. Hartmut J?ger

    RobG Guest

    Hartmut J?ger wrote:
    [...]
    > I want to move a GIF-Animation on the document window. In IE6 all runs
    > well.


    Because Microsoft seems to find it amusing to allow invalid markup and
    scripting to work on an /ad hoc/ basis.

    --
    Rob
     
    RobG, Nov 28, 2004
    #4
  5. RobG <> wrote in message news:<41a917e8$0$25789$>...
    > Hartmut Jaeger wrote:
    > [...]
    > > I want to move a GIF-Animation on the document window. In IE6 all runs
    > > well.

    >
    > Because Microsoft seems to find it amusing to allow invalid markup and
    > scripting to work on an /ad hoc/ basis.


    Thanks to all for your answers. It works fine now with Firefox. Seems,
    that I use the wrong books, because I can read in SelfHTML (a german
    online book) document.getElementById["...."] with [] paranthesis.

    And a peaceful christmas time to you all. Hartmut
     
    Hartmut J?ger, Nov 28, 2004
    #5
  6. Martin Bialasinski, Nov 28, 2004
    #6
  7. Michael Winter, Nov 28, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TR
    Replies:
    5
    Views:
    131
    Richard Cornford
    May 19, 2004
  2. Andrea
    Replies:
    5
    Views:
    201
    Thomas 'PointedEars' Lahn
    Nov 30, 2005
  3. the other john

    getElementById and Firefox

    the other john, May 24, 2006, in forum: Javascript
    Replies:
    4
    Views:
    142
    the other john
    May 24, 2006
  4. the other john

    getElementById and Firefox

    the other john, May 24, 2006, in forum: Javascript
    Replies:
    0
    Views:
    164
    the other john
    May 24, 2006
  5. Firefox and getElementById

    , Sep 25, 2006, in forum: Javascript
    Replies:
    8
    Views:
    165
Loading...

Share This Page