CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   HTML & CSS (http://www.codingforums.com/forumdisplay.php?f=13)
-   -   Different background per resolution (http://www.codingforums.com/showthread.php?t=1146)

Tombo 07-01-2002 07:28 PM

Different background per resolution
 
Hullo,

I was wondering if there was a script I could use on my page that will choose a back ground image based on what the user's resolution is. For example, I wanted to use a photo as the site's background, but wanted to ensure that users with a 640x480 resolution will see the entire photo, as well as users with 1024x768, without wasted space around the image.

If there's a script I can put in the page's header that will choose the right background image based on the user's resolution, then that would be great. If there's a script that will redrect the user to a different page based on their resolution, that would be just as good (and actually more preferable.)

Anyways, that's my query. Thanks.

Jeepers 07-01-2002 07:51 PM

screen.width gives the horizontal resolution and screen.height gives vertical resolution.

var scrWidth = screen.width;
var scrHeight= screen.height;
if (scrWidth=800 && scrHeight=600) {top.location.href="800X600 page"}
else
if (scrWidth=1024 && scrHeight=768) {top.location.href="1024X768 page"}

etc etc

This will get the screen resolution and then redirect to the correct page for that resolution. You may also have to think about the browser window size. You can detect this by:
Netscape ~ window.innerWidth and window.innerHeight
IE ~ document.body.clientWidth and document.body.clientHeight

Quiet Storm 07-01-2002 11:13 PM

Or you could have the background adjust itself - will always be whatever width the screen is...


All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.