• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Javascript resolution detection

Vegitto

Diamond Member
I'm trying to display an image, and the size of the image depends on the user's resolution. IE, if the user uses 800x600, I want the image to be 500x400. If the user uses 1024x768, I want to image to be 800x600. And finally, if the user uses >1024x768, I want the image to be 1024x768. How do I do this?

Thanks in advance 🙂.
 
You really want those dimensions? The aspect ratio is changing. Why do you want to do this? Is there something wrong with setting a width to some percent AND a max-width? Do you really want this to depend on screen resolution rather than browser window size?
 
This code will more or less do what you want. Keep in mind that you can only detect browser size, not desktop resolution size. Also, the dimensions you proposed will distort the original image as CTho9305 mentioned.
 
Originally posted by: CTho9305
You really want those dimensions? The aspect ratio is changing. Why do you want to do this? Is there something wrong with setting a width to some percent AND a max-width? Do you really want this to depend on screen resolution rather than browser window size?

I meant browser window size, and the values given were just dummy-values. There's a lot more 😛.
 
It works! THANKS! 🙂

Only, IE gives me security crap about the script trying to read my 'user settings' or something. Can I do something about that?
 
Originally posted by: Vegitto
It works! THANKS! 🙂

Only, IE gives me security crap about the script trying to read my 'user settings' or something. Can I do something about that?

If you run it via a web server (IIS, Apache, etc.) and not as a local file off of your hard drive, you won't get that message. IE 6 SP2 warns about any JavaScript that is executed locally.
 
Originally posted by: MrChad
Originally posted by: Vegitto
It works! THANKS! 🙂

Only, IE gives me security crap about the script trying to read my 'user settings' or something. Can I do something about that?

If you run it via a web server (IIS, Apache, etc.) and not as a local file off of your hard drive, you won't get that message. IE 6 SP2 warns about any JavaScript that is executed locally.

Okay, thanks a lot 🙂.
 
Back
Top