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 4 of 4
  1. #1
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    offsetLeft in Moz

    is there any possibility to get the real offsetLeft in Mozilla for an element positioned only with align="center" ? It works only for IE...

    PHP Code:
    <!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> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Would it work if you used CSS's auto margin instead of the 'outdated' align?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,695
    Thanks
    0
    Thanked 232 Times in 227 Posts
    Hi there kor,

    it looks like a bug to me.
    Why don't you post this question here.
    You may get some interesting observations.

    coothead

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Solve it

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

    PHP Code:
    <!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').offsetParent.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> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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