...

View Full Version : offsetLeft in Moz



Kor
03-21-2005, 06:04 PM
is there any possibility to get the real offsetLeft in Mozilla for an element positioned only with align="center" ? It works only for IE...



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
onload=function(){
alert(document.getElementById('container').offsetLeft)
}
</script>
<style type="text/css">
body {
margin-top: 0px;
margin-left: 0px;
}
</style>
</head>
<body>
<table width="400" align="center" id="container">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</body>
</html>

A1ien51
03-21-2005, 06:43 PM
Would it work if you used CSS's auto margin instead of the 'outdated' align?

Eric

coothead
03-21-2005, 06:45 PM
Hi there kor,

it looks like a bug to me. :eek:
Why don't you post this question here (http://forums.mozillazine.org/viewforum.php?f=9&sid=52ff47930587c920a6b34ce8a27d01a7).
You may get some interesting observations.

coothead

Kor
03-22-2005, 09:06 AM
I have tried a rather unothodox solution, give tbody the id...

To my surprise, it works...But in that way it woun't work for IE... :D Now if add the offsetParent I get something which is really usefull. Well, there are still 11px difference betweeen IE and Moz, but with a small detector I am able to solve it...Or maybe I don't need that, as the difference must be the IE's stupid vertical scrollbar, and, in fact, I need that value only as an anchor for other absolute positioned objects in page.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
onload=function(){
alert(document.getElementById('container').offsetLeft+document.getElementById('container').offsetPar ent.offsetLeft)
}
</script>
<style type="text/css">
body {
margin-top: 0px;
margin-left: 0px;
}
</style>
</head>
<body>
<table width="400" align="center">
<tbody id="container">
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum