NS v. IE

Discussion in 'Javascript' started by Lee Davidson, Jun 27, 2003.

  1. Lee Davidson

    Lee Davidson Guest

    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";
    }
     
    Lee Davidson, Jun 27, 2003
    #1
    1. Advertisements

  2. Lee Davidson

    Lee Davidson Guest

    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
     
    Lee Davidson, Jun 27, 2003
    #2
    1. Advertisements

  3. Lee Davidson

    Markus Ernst Guest

    The correct syntax for the inline css is:

    style="position:absolute; z-index:3px; left:0px; top:5px"
     
    Markus Ernst, Jun 27, 2003
    #3
  4. Typos in the CSS, you use "=" where you should use ":" and you
    have forgotten the units on the value of top, i.e.,

    Should be
    <script type="text/javascript">
    In HTML 4, the type attribute is mandatory and the language attribute
    is deprecated.
    As above. You might want to change "left:90%" to "right:0px".
    As above
    I assume the "days" variable is initalized earlier.
    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.
    As long as it isn't used for anything but NS4, it shouldn't be a
    problem.
    type="text/javascript"

    (yes, I'm pedantic :)
    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.)
    I'm pretty stumped too. Could you give a link to the page, so I can
    see it live?
    I hear testosterone will do that to you. That's my excuse :)

    /L
     
    Lasse Reichstein Nielsen, Jun 27, 2003
    #4
  5. Lee Davidson

    Lee Davidson Guest

    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
     
    Lee Davidson, Jun 27, 2003
    #5
    1. Advertisements

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