Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-01-2002, 07:28 PM   PM User | #1
Tombo
New Coder

 
Join Date: Jun 2002
Location: Canada
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Tombo is an unknown quantity at this point
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.
__________________
Tombo out.
Tombo is offline   Reply With Quote
Old 07-01-2002, 07:51 PM   PM User | #2
Jeepers
Regular Coder

 
Join Date: Jun 2002
Location: Conwy. UK
Posts: 122
Thanks: 0
Thanked 0 Times in 0 Posts
Jeepers is an unknown quantity at this point
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
__________________
An answer needs a question just as much as a question needs an answer. Deep eh!
Jeepers is offline   Reply With Quote
Old 07-01-2002, 11:13 PM   PM User | #3
Quiet Storm
Regular Coder

 
Join Date: Jun 2002
Location: Beyond Lament
Posts: 424
Thanks: 0
Thanked 0 Times in 0 Posts
Quiet Storm is an unknown quantity at this point
Or you could have the background adjust itself - will always be whatever width the screen is...
__________________
Quíet Storm Designs ~ Art is not what you see, but what you make others see.
· the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·
Quiet Storm is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:05 AM.


Advertisement
Log in to turn off these ads.