[Javascript] getting relative position in multiple resolutions

Russell Scheinberg rscheinberg at lrk.com
Mon Apr 23 17:49:51 CDT 2001


I am using Heirmenus to display cascading menus. They work really well. However, I am using absolute positioning of the menu to align it correctly with an image I am using. The problem is that this pixel point will change depending on the resolution of the browser displaying it.  I can get the resolutiion of the user agent with screen.height and screen.width and even the screen.availheight and screen.availwidth. I thought that if I took the point in one resolution say 1024 X 768 and created a formula, that would work in all resolutions. 

So if the point is set at 595 from the left edge of the screen in that res, then 595/1024 would be .581. Then I could set the relative point as .581*screen.height or .581*screen.availheight or something like that. Unfortunately, that doesn't work and sends the location of the menu all over the place in other resolutions. 

I was wondering if there is a way to get the pixel point of an image element and then work from there. Any ideas? Thanks.





More information about the Javascript mailing list