Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-06-2004, 03:21 AM   #1
Member (7 bit)
 
Join Date: Mar 2004
Location: Sacramento, CA
Posts: 86
Send a message via AIM to mrdeeye
Javascript Screen Res detection question

I was wondering if i could write an if else javascript that would use one stylesheet for one resolution and one for another....like one script for 1024x768 and one for anything lower than that?
mrdeeye is offline   Reply With Quote
Old 09-06-2004, 05:45 PM   #2
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
PHP Code:
<script language="Javascript1.2">
<!-- 
// please keep these lines on when you copy the source
// made by: Nicolas - [url]http://www.javascript-page.com[/url]

if (screen.width <= 640) {
alert("Since you have a smaller screen size (640x480).  I'll redirect you to the appropriate page for your screen.");
document.location "screenres2.html";
}

else if (
screen.width <= 800) {
alert("You have an average screen size (800x600).  I'll redirect you to the appropriate page for your screen.");
document.location "screenres2.html";
}

if (
screen.width 800) {
alert("You have a large screen size.  I'll redirect you to the appropriate page for your screen.");
document.location "screenres2.html";
}

//-->
</script> 
You may not want the alerts if you want the redirection to be automatic.
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
Force Flow is offline   Reply With Quote
Old 09-06-2004, 09:13 PM   #3
Member (7 bit)
 
Join Date: Mar 2004
Location: Sacramento, CA
Posts: 86
Send a message via AIM to mrdeeye
im sorry if my original post was a bit unclear. I was wondering though, if there was a way to write a script so if the resolution was say 800x600 it would include one style sheet or if it was higher than that it would include another. Or is the only way to do that is to have seperate html files for each one and redirect them accordingly? Sorry again for the confusion.

- deeye
mrdeeye is offline   Reply With Quote
Old 09-07-2004, 07:53 AM   #4
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
I don't know if there is way to load different CSS files. The most common way to handle different screen sizes is by a redirection to different html files.
Force Flow is offline   Reply With Quote
Old 09-07-2004, 09:39 AM   #5
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Here are a couple of examples of what you are trying to do;

Example 1
Example 2
__________________

Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row
mairving is offline   Reply With Quote
Old 09-07-2004, 01:11 PM   #6
Member (7 bit)
 
Join Date: Mar 2004
Location: Sacramento, CA
Posts: 86
Send a message via AIM to mrdeeye
once again marving BRAVO! That was exactly what i was talking about. thanks!
mrdeeye is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes 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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:52 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2