...

View Full Version : Small different w/ width&height and offsetLeft in ie6/ff



bigtiger
06-01-2007, 02:38 AM
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,

koyama
06-02-2007, 04:48 AM
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)

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum