[Javascript] getting relative position in multiple resolutions

BEKIM BACAJ Trojani2000 at hotmail.com
Thu Apr 26 08:20:15 CDT 2001


If I understood correctly, you are using an image for adjusting you're menu?
Well. Anyway, the problem is caused by the absolute size of the image that will cover relative portion of the users screen depending on monitor resolution settings.
If you're formula works fine with other elements, there is no reason to fail with the image, all you have to do is, use/apply you're formula in the image size too.
<img id=thatImage src="itsLocation\theImage.gif">

...on the script, acces it's properties like u usualy do, and specify the new deppendable size suitable to current resolution.
...
thatImage.style.width=the_formulaResult+'px'
thatImage.style.height=the_formulaResult+'px'
...

In this casse, it is preferable to use pictures created for higher resolutions like 1024/768, 1152/864; 1280/960; 1280/1024,  
because if u use 800/600 res., you have to enlarge it with u're formula for res., like 1024/768 or higher 1280/1024.
This way the image will get poor in the user's screen.

Or, there is an alternative way. You will have to create different images for different resolution's and ref to them after the update of user's screen res.

if this that
if this that
if this that
//for every screen resolution  and image you might have.
if this //supose it has answered the 1024/768 resolution
//than we take action like
thatImage.src="itsLocation\theImage1024/768.gif"


or we can simplify

scrRes, global var of the user screen resolution determined with you're other function

function theRightImage(){//or Images perhaps?!

thatImage.src="itsLocation\theImage" + scrRes +".gif"
thisImage.src="itsLocation\otherImage" + scrRes +".jpg"
...
}
call this function from inside  res., determiner function


-Hope it helps
 Regards
----- Original Message -----
From: Russell Scheinberg
Sent: Tuesday, April 24, 2001 12:54 AM
To: javascript at LaTech.edu
Subject: [Javascript] getting relative position in multiple resolutions


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 drepoint 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.


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript<br clear=all><hr>Get Your Private, Free E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<br></p>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010426/70f25ce5/attachment.htm>


More information about the Javascript mailing list