Firefox and getElementById

H

Hartmut J?ger

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
 
M

Martin Honnen

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';
 
R

RobG

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.
 
H

Hartmut J?ger

RobG said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,260
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top