New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

Safari Javascript problem

Post Reply New Thread Subscribe

Thread Tools
Posts: n/a

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:

<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') = topPos;

window.onload = testfunction;
<table border="1px" width="100%">
<td width="40%">
<span style="font-size:xx-large;">Header</span>
Logo goes here
<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
<li>upper left corner of Content cell</li>
Position is
<li>partly outside and vertically in the middle of the cell</li>
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?
QUOTE Thanks

Post Reply New Thread Subscribe

« Font Creator | Can somebody check my site on MAC? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
designing for safari problem cyanide Web Design and Hosting 5 02-02-2004 02:19 AM
Startup problem OS 10.2 and G4 450 AGP lvinay OS X - Operating System 2 09-30-2003 11:21 AM

All times are GMT -4. The time now is 11:44 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?