Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Firefox and getElementById

Reply
Thread Tools

Firefox and getElementById

 
 
Hartmut J?ger
Guest
Posts: n/a
 
      11-27-2004
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
 
Reply With Quote
 
 
 
 
Mick White
Guest
Posts: n/a
 
      11-27-2004
Hartmut J?ger wrote:

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


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

Mick
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      11-27-2004


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/
 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      11-28-2004
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
 
Reply With Quote
 
Hartmut J?ger
Guest
Posts: n/a
 
      11-28-2004
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
 
Reply With Quote
 
Martin Bialasinski
Guest
Posts: n/a
 
      11-28-2004
(Hartmut J?ger) wrote:

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


URL?

http://de.selfhtml.org/javascript/ob..._element_by_id
is correct

 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      11-28-2004
On Sun, 28 Nov 2004 14:51:39 +0100, Martin Bialasinski
<agr30+> wrote:

[snip]

> http://de.selfhtml.org/javascript/ob..._element_by_id
> is correct


Aside from the remarkably bad example, yes.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox and getElementById jason.hau@gmail.com Javascript 8 09-26-2006 08:48 AM
getElementById and Firefox the other john Javascript 4 05-24-2006 08:50 PM
getElementById and Firefox the other john Javascript 0 05-24-2006 06:25 PM
firefox and problems with getElementById Andrea Javascript 5 11-30-2005 11:56 PM
getElementbyId problem in Firefox TR Javascript 5 05-19-2004 12:18 PM



Advertisments