Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Digital Lifestyle
Web Design and Hosting
Safari Javascript problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="babszem" data-source="post: 22717"><p>Hi everyone! First of all sorry for not posting the thing below as a link, but unfortunately I don't have access to a handy website right now to upload it there.</p><p></p><p>My problem is that the html page and script below works on every browser I could put my hands on right now (that doesn't mean all of them of course, but quite some - IE, Mozilla, Opera...), except on Safari. I cannot figure out what could be the problem, because a lot of googling on the net turned up this findPos script as a fail-safe one that would work on all browsers. Safari seems to ignore this however...</p><p></p><p>Please could anyone:</p><p>1. Confirm my problem (see the contents of the layer).</p><p>2. Suggest any alternative to getting the correct position in Safari.</p><p></p><p>Thanks a lot:</p><p> Babszem.</p><p></p><p><html></p><p> <head></p><p> <title>Safari Javascript bug testcase</title></p><p> <script type="text/javascript"></p><p> function findPosX(obj)</p><p> {</p><p> var curleft = 0;</p><p> if (obj.offsetParent)</p><p> {</p><p> while (obj.offsetParent)</p><p> {</p><p> curleft += obj.offsetLeft</p><p> obj = obj.offsetParent;</p><p> }</p><p> }</p><p> else if (obj.x)</p><p> curleft += obj.x;</p><p> return curleft;</p><p> }</p><p> </p><p> function findPosY(obj)</p><p> {</p><p> var curtop = 0;</p><p> if (obj.offsetParent)</p><p> {</p><p> while (obj.offsetParent)</p><p> {</p><p> curtop += obj.offsetTop</p><p> obj = obj.offsetParent;</p><p> }</p><p> }</p><p> else if (obj.y)</p><p> curtop += obj.y;</p><p> return curtop;</p><p> }</p><p></p><p> function testfunction ()</p><p> {</p><p> leftPos = findPosX (document.getElementById('testcell'));</p><p> topPos = findPosY (document.getElementById('testcell'));</p><p> document.getElementById('testlayer').style.left = leftPos;</p><p> document.getElementById('testlayer').style.top = topPos;</p><p> }</p><p></p><p> window.onload = testfunction;</p><p> </script></p><p> </head></p><p> <body></p><p> <table border="1px" width="100%"></p><p> <tr></p><p> <td width="40%"></p><p> <span style="font-size:xx-large;">Header</span></p><p> </td></p><p> <td></p><p> Logo goes here</p><p> </td></p><p> </tr></p><p> <tr></p><p> <td id="testcell" colspan="2" height="500px"></p><p> <div id="testlayer" style="position<img src="/images/smilies/angel.gif" class="smilie" loading="lazy" alt=":a" title="Angel :a" data-shortname=":a" />bsolute; left:0px; top:0px; width:500px; height:200px; z-index=10; background-color:#8888FF;"></p><p> Layer should start in</p><p> <ul></p><p> <li>upper left corner of Content cell</li></p><p> </ul></p><p> Position is</p><p> <ul></p><p> <li>partly outside and vertically in the middle of the cell</li></p><p> </ul></p><p> Conclusion: <code>findPos ()</code> functions only return position of "Content" text relative to table upper left corner. (I asked for content <u>cell</u>.) Why?</p><p> </div></p><p> Content</p><p> </td></p><p> </tr></p><p> </table></p><p> </body></p><p></html></p></blockquote><p></p>
[QUOTE="babszem, post: 22717"] Hi everyone! First of all sorry for not posting the thing below as a link, but unfortunately I don't have access to a handy website right now to upload it there. My problem is that the html page and script below works on every browser I could put my hands on right now (that doesn't mean all of them of course, but quite some - IE, Mozilla, Opera...), except on Safari. I cannot figure out what could be the problem, because a lot of googling on the net turned up this findPos script as a fail-safe one that would work on all browsers. Safari seems to ignore this however... Please could anyone: 1. Confirm my problem (see the contents of the layer). 2. Suggest any alternative to getting the correct position in Safari. Thanks a lot: Babszem. <html> <head> <title>Safari Javascript bug testcase</title> <script type="text/javascript"> function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } function testfunction () { leftPos = findPosX (document.getElementById('testcell')); topPos = findPosY (document.getElementById('testcell')); document.getElementById('testlayer').style.left = leftPos; document.getElementById('testlayer').style.top = topPos; } window.onload = testfunction; </script> </head> <body> <table border="1px" width="100%"> <tr> <td width="40%"> <span style="font-size:xx-large;">Header</span> </td> <td> Logo goes here </td> </tr> <tr> <td id="testcell" colspan="2" height="500px"> <div id="testlayer" style="position:absolute; left:0px; top:0px; width:500px; height:200px; z-index=10; background-color:#8888FF;"> Layer should start in <ul> <li>upper left corner of Content cell</li> </ul> Position is <ul> <li>partly outside and vertically in the middle of the cell</li> </ul> Conclusion: <code>findPos ()</code> functions only return position of "Content" text relative to table upper left corner. (I asked for content <u>cell</u>.) Why? </div> Content </td> </tr> </table> </body> </html> [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
Digital Lifestyle
Web Design and Hosting
Safari Javascript problem
Top