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
babszem
Guest
 
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:
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 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
Thread Starter
Forum
Replies
Last Post
designing for safari problem cyanide Web Design and Hosting 5 02-02-2004 03:19 AM
Startup problem OS 10.2 and G4 450 AGP lvinay OS X - Operating System 2 09-30-2003 12:21 PM

All times are GMT -4. The time now is 10:39 AM.

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

Welcome to Mac-Forums.com

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?