Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder bigtiger's Avatar
    Join Date
    Oct 2005
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Small different w/ width&height and offsetLeft in ie6/ff

    Hi, all.

    newer to CSS and js.

    When working with ff and ie6. The latter is very not w3c conformed. As the example below. With the style of the first div tag was marked with width or height property. It is treaded it as a dummy positioned element. So the offsetParent was pointed to closest positioned node instead of html or body.

    Any easy way for this ?

    <div style="position:static;margin-left:100px;width:100px;border: solid 1px #000000" id="top">
    <div id="pp1">
    <div onclick="alert(this.offsetParent.tagName + ' ' + this.offsetParent.id + ' ' + this.offsetLeft)" style="background-color:lightblue;left:0">item1</div>
    <span onclick="alert(this.offsetParent.tagName + ' ' + this.offsetHeight)" style="background-color:lightblue;height:20px">item1</span>
    </div>
    </div>


    Also, any jsdom reference to download. I have got an old reference with the url of my page: http://enekz.frih.net/dev/web/jsdom. But this was longer.

    Thanks,

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by bigtiger View Post
    When working with ff and ie6. The latter is very not w3c conformed. As the example below. With the style of the first div tag was marked with width or height property. It is treaded it as a dummy positioned element. So the offsetParent was pointed to closest positioned node instead of html or body.

    Any easy way for this ?
    I'm not really sure about your question?

    Looking at your code, you seem to be missing a couple of things.

    (1)
    Code:
    <div onclick="alert(this.offsetParent.tagName + ' ' + this.offsetParent.id + ' ' +
    this.offsetLeft)" style="background-color:lightblue;left:0">item1</div>
    Offset properties top, right, left, and bottom do not apply to non-positioned elements.

    (2)
    Code:
    <span onclick="alert(this.offsetParent.tagName + ' ' + this.offsetHeight)" 
    style="background-color:lightblue;height:20px">item1</span>
    width and height do not apply to non-replaced inline elements.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •