Thomas J.S.: Auslesen von CSS-Attributen mit dem IE, einfach?

Beitrag lesen

Hallo hambam!

Also, das Problem liegt wohl daran, daß du dein #copyright nicht "richtig" positioniert hast:
#copyright {position:absolute; text-align:center;z-index:100;}

Da ist nämlich wirklich kein Wert da um ausgelesen zu werden. (du kannst so nur offsetLeft abfragen.)

Hier einige Links von MS wie der IE es macht:
http://msdn.microsoft.com/workshop/author/om/measuring.asp#chp_measuring
http://msdn.microsoft.com/workshop/Author/dhtml/reference/properties/pixelLeft.asp

Der folgende Code funktioniert:

Grüße
Thomas

<html>
<head>
<style type="text/css">
#copyright {
position:absolute;
top:130px;
left:200px;
width:300px;
height:30px;
border:solid 1px blue;
z-index:3;
}
</style>
</head>
<body>

<div id="copyright">© Alle Rechte vorbehalten</div>
<div id="copyright2">© Alle Rechte vorbehalten</div>
<script>
document.all.copyright2.style.pixelLeft = 300;
alert("pixelLeft ist:" + copyright2.style.pixelLeft);
alert("offsetLeft ist:" + copyright2.offsetLeft);
alert("left ist:" + copyright.currentStyle.left);
alert("top ist:" + copyright.currentStyle.top);
alert("width ist:" + copyright.currentStyle.width);
alert("height ist:" + copyright.currentStyle.height);
alert("zIndex ist:" + copyright.currentStyle.zIndex);
</script>
</body>
</html>

PS: ersetze mal copyright2 durch:
<div id="copyright2" style="position:absolute;">© Alle Rechte vorbehalten</div>