CSS in Mozilla (Firefox)

T

Tim Slattery

I have a div that's defined like so:

<div id="footer">
footer text for web pages
</div>

In the stylesheet is this entry:

#footer {
background-color: #006600;
position: absolute;
top: 410px;
left: 0px;
width: 100%;
z-index: 4;
border: 1px solid #009900;
border-width: 2px 0px 1px 0px;
}

And following the DIV in the HTML file is a Javascript block that
assigns a position for this div, like so:

ftr = document.getElementByPosition("footer")
ftr.style.top = iTop;

where iTop has been calculated earlier in the Javascript. This works
correctly in Internet Explorer. When I put alerts in the script, I see
the page displayed with the footer at 410 pixels (as per the style
sheet), then it jumps to the newly assigned position.

In Mozilla Firefox, the footer never moves. The "calculated style" in
the DOM browser *always* shows the value 410 (from the style sheet),
*never* the assigned value. What's more, trying to display
ftr.style.top results in a blank.

So what's up? It's not a timing issue, when I trigger the Javascript
long after the page loads the result is the same. Is there different
syntax in Mozilla-land for addressing stsyle elements? Or is this a
Mozilla bug? (It does the same thing in NS7)
 
M

Mark Preston

Tim said:
I have a div that's defined like so:

<div id="footer">
footer text for web pages
</div>

[snip]
And following the DIV in the HTML file is a Javascript block that
assigns a position for this div, like so:

ftr = document.getElementByPosition("footer")
ftr.style.top = iTop;

[snip]
In Mozilla Firefox, the footer never moves. The "calculated style" in
the DOM browser *always* shows the value 410 (from the style sheet),
*never* the assigned value. What's more, trying to display
ftr.style.top results in a blank.
One thing that immediately springs to mind is to ask why you have not
used the more sensible statement:-

ftr = document.getElementById ("footer")

What happens if you use that?
 

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

No members online now.

Forum statistics

Threads
474,472
Messages
2,571,834
Members
48,802
Latest member
shadowoftheunknown
Top