View Full Version : Safari issue with coordinates and scrollTo

01-24-2005, 07:53 AM
I've set up a small function that uses moveTo to center a position in the browser window:

function centerScroll(xx,yy){
var xpos
var ypos

xpos = xx - document.body.clientWidth/2
ypos = yy - document.body.clientHeight/2

scrollTo(xpos, ypos)

This function is accessed from a link:

<a href="javascript:centerScroll(1462, 1725);">Go!</a>

Those coordinates are about center of a very large document nearly 3000px X 3000px in size.

I've tested the code in Explorer and Firefox in Windows XP and OS X and it works perfectly. When I've tested in Safari, however, it moves to the x-coordinate without a problem, but it doesn't move to the y-coordinate properly. It hits at about 500 or 600 pixels down from the top of the browser, but not the full 1725. Oddly enough, when I put in the coordinates (1462, 3000) it hits the right mark just fine.

So I have two questions:

1.) Is there a better way to do this that will work on all browsers?
2.) If there isn't, how do Safari coordinates work? I could use a browser detect function that takes in coordinates and fixes them to work on the user's browser, but I'd need to know a general rule for converting coordinates.

I appreciate any help on this.

To see the script in action, go to http://www.appfilmfest.org/draft and click "How To Submit".

01-24-2005, 07:09 PM
I can't see the code. I've e-mailed the admins on this but they are ignoring my complaint.

Willy Duitt
01-24-2005, 08:31 PM
I can't see the code. I've e-mailed the admins on this but they are ignoring my complaint.

That's what happens when you use a MAC when you should be using a PC... :D
And I doubt the admins have been ignoring you, especially with as many posts on the board as you have... But, this is an issue of the way vBulletin displays CODE and PHP tags in a division in such a way that some MAC/BROWSER combinations can not support and thus is out of their hands...

Besides, if all your message to the admins said is what you said here "I can't see the code"
They probably did not, could not understand what you meant...