NS v. IE

L

Lee Davidson

I can move a couple of layers in IE, but they are not moving in NS.
What is wrong with this?

if (NS4)
{
document.word1.left = mv1From;
}
else if (NS6)
{
document.getElementById('word1').style.left = mv1From + "px";
}
else if (IE)
{
document.all.word1.style.left = mv1From + "px";
}
 
L

Lee Davidson

Thanks for your response. The objects are:

<div id=word1 style="position:absolute; z-index=3; Left=0; top=5">
<SCRIPT LANGUAGE="javascript">
document.write("'04 election in:");
</SCRIPT>
</div>

<div id=word2 style="position:absolute; z-index:2; Left=90%; top=5">
<SCRIPT LANGUAGE="javascript">
document.write(days + " Days")
</SCRIPT>
</div>

or actually divisions, not layers. I was lazily using a generic name.
Sorry for the confusion.

I had printed the values to the screen so I know the various flags are
set correctly (at least NS6 and IE) as I'm using NS7.

I doubt many people are using NS4 anymore, but I left that in just
because it wasn't hurting anything.

I used your wonderful page (please keep it around a while) to see that
document.body.clientWidth returns the value in both IE and NS. But when
I try to display it with an alert box:

<BODY onload="init()">

<script>

var scrWidth = document.body.clientWidth;
alert("sw " + scrWidth);

it comes up as 0. So all the math is failing and the move not reached.
I do see the proper number when your page is displayed in NS so I
know the browser does see the width.

Now you know why I'm losing my hair.

Lee
 
M

Markus Ernst

Lee Davidson said:
Thanks for your response. The objects are:

<div id=word1 style="position:absolute; z-index=3; Left=0; top=5">
<SCRIPT LANGUAGE="javascript">
document.write("'04 election in:");
</SCRIPT>
</div>

<div id=word2 style="position:absolute; z-index:2; Left=90%; top=5">
<SCRIPT LANGUAGE="javascript">
document.write(days + " Days")
</SCRIPT>
</div>

The correct syntax for the inline css is:

style="position:absolute; z-index:3px; left:0px; top:5px"
 
L

Lasse Reichstein Nielsen

Lee Davidson said:
Thanks for your response. The objects are:

<div id=word1 style="position:absolute; z-index=3; Left=0; top=5">

Typos in the CSS, you use "=" where you should use ":" and you
have forgotten the units on the value of top, i.e.,

<SCRIPT LANGUAGE="javascript">

Should be
<script type="text/javascript">
In HTML 4, the type attribute is mandatory and the language attribute
is deprecated.
document.write("'04 election in:");
</SCRIPT>
</div>

<div id=word2 style="position:absolute; z-index:2; Left=90%; top=5">

As above. You might want to change "left:90%" to "right:0px".
<SCRIPT LANGUAGE="javascript">

As above
document.write(days + " Days")

I assume the "days" variable is initalized earlier.
</SCRIPT>
</div>

or actually divisions, not layers. I was lazily using a generic name.
Sorry for the confusion.

Many people say "layers" about absolutely positionend block elements.
I try to make them stop, partly because it can be confuzed with the
<layer> tag, but mostly because it makes people think that there is
something special about the positioned block. In CSS, it's just a
block like any other.
I had printed the values to the screen so I know the various flags are
set correctly (at least NS6 and IE) as I'm using NS7.
Ok.

I doubt many people are using NS4 anymore, but I left that in just
because it wasn't hurting anything.

As long as it isn't used for anything but NS4, it shouldn't be a
problem.
I used your wonderful page (please keep it around a while) to see that
document.body.clientWidth returns the value in both IE and NS. But
when I try to display it with an alert box:
<BODY onload="init()">

<script>

type="text/javascript"

(yes, I'm pedantic :)
var scrWidth = document.body.clientWidth;
alert("sw " + scrWidth);

it comes up as 0.

I can't explain (or reproduce) that. Do you have a link to the page?

Does the page set the broweser in Quirks mode or Standards mode? I
test the values in Standards mode (the only mode one should write new
pages for!), and it might make a difference.

Some value are not initialized until the page is loaded, or at least
contains some content. Your example here gets
document.body.clientWidth before any content is added to the body. I
don't think it matters, it's the height that has that problem, not the
width.

I don't think that is the problem, though (can't reproduce a problem
with it in either Standards or Quirks mode.)
So all the math is failing and the move not reached. I do see the
proper number when your page is displayed in NS so I know the
browser does see the width.

I'm pretty stumped too. Could you give a link to the page, so I can
see it live?
Now you know why I'm losing my hair.

I hear testosterone will do that to you. That's my excuse :)

/L
 
L

Lee Davidson

First, thanks for the help (and Markus that applies to you as well).

Second, I think the lack of objects on the page must have been the
problem as both browsers showed your wonder test page just fine. I
switched from "body" to "documentElement" and it picked up the size.

Third, I have no idea what "Quirks" mode is.

The working page is www.democratsforum.com and the testing page is
www.democratsforum.com/textframe.htm. I put in an "alert" and in IE the
document.body.clientWidth shows as expected, but not in NS.
Yet it does show when printed to the page as in your test position page.

Anyway, it looks as if this is working now (perhaps not in Opera). I
have a friend that uses that one and will ask him to check it out.

Lee
 

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
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top