P
philjhanna
Hi,
In the example code below can anyone tell me why the first link alerts
an empty string but the second alerts the width? The only difference is
the way the left: 20px; is applied but I wouldn't have thought this
should matter.
This occurs in both Firefox (1.0.2) and IE6 (On Win XP SP2).
This appears to be the behaviour no matter what style is applied (e.g.
border's too).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style>
#testDiv1{
position:relative;
left: 50px;
}
</style>
</head>
<body>
<div id="testDiv1">testDiv1</div>
<div id="testDiv2" style="position:relative; left:
50px;">testDiv2</div>
<a
href="javascript:alert(document.getElementById('testDiv1').style.left)">alert
testDiv1 width</a>
<a
href="javascript:alert(document.getElementById('testDiv2').style.left)">alert
testDiv2 width</a>
</body>
</html>
Many thanks to anyone who can shed some light on this.
Cheers,
Phil
In the example code below can anyone tell me why the first link alerts
an empty string but the second alerts the width? The only difference is
the way the left: 20px; is applied but I wouldn't have thought this
should matter.
This occurs in both Firefox (1.0.2) and IE6 (On Win XP SP2).
This appears to be the behaviour no matter what style is applied (e.g.
border's too).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style>
#testDiv1{
position:relative;
left: 50px;
}
</style>
</head>
<body>
<div id="testDiv1">testDiv1</div>
<div id="testDiv2" style="position:relative; left:
50px;">testDiv2</div>
<a
href="javascript:alert(document.getElementById('testDiv1').style.left)">alert
testDiv1 width</a>
<a
href="javascript:alert(document.getElementById('testDiv2').style.left)">alert
testDiv2 width</a>
</body>
</html>
Many thanks to anyone who can shed some light on this.
Cheers,
Phil