Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 01-03-2007, 10:51 PM Messed up script
Extreme Talker

Posts: 217
Trades: 0
I am trying to get a script working that detects the users resolution and then changes the stylesheet to a optimized one (for 800x600, only res the style doesnt seem to work right on). I found this script: http://javascript.internet.com/user-...n-details.html and modified it a bit to change the stylesheet instead, but the result was that no matter what resolution I was on it always changed to teh alternate version.

So I messed around a bit and got this:

Code:
<!-- This script and many more are available free online at 

-->
<!-- The JavaScript Source!! http://javascript.internet.com 

-->

<!-- Begin
var screen_width = null;
var screen_height = null;
var resolution = null;

screen_width = screen.width;
screen_height = screen.height;


if (screen_width = "800" && screen_height = "600") {
document.write("<style 

type='text/css'>@import'stylealt.css';</style>");
}
else {

}
// End -->
(got that after doing a bit of googleing)
anyways that doesnt work at all. On the original script it switched to the alternate style no matter what. With my modified version it never switches to the alternate, despite being on 800 x 600.

Any clues on where I can get a working script/how I can fix this one?
__________________

Please login or register to view this content. Registration is FREE
Slick Nick is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-03-2007, 11:59 PM Re: Messed up script
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by Slick Nick View Post
I am trying to get a script working that detects the users resolution and then changes the stylesheet to a optimized one

Any clues on where I can get a working script/how I can fix this one?
The problem is very simple and obvious, but 'fixing' it won't really fix anything.
The real answer is to fix your CSS to cope with different screen resolutions, so I recommend that you ask in a CSS forum.
logic ali is offline
Reply With Quote
View Public Profile
 
Old 01-04-2007, 12:18 AM Re: Messed up script
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
You are using the wrong syntax in your evaluation statement. You are using:

Code:
if (screen_width = "800" && screen_height = "600")
Using = will overwrite the var and will always evaluate to true. You should use == to evaluate:

Code:
if (screen_width == "800" && screen_height == "600")
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 01-04-2007 at 12:26 AM..
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 01-04-2007, 12:31 AM Re: Messed up script
Extreme Talker

Posts: 217
Trades: 0
Quote:
Originally Posted by mgraphic View Post
You are using the wrong syntax in your evaluation statement. You are using:

Code:
if (screen_width = "800" && screen_height = "600")
Using = will overwrite the var and will always evaluate to true. You should use == to evaluate:

Code:
if (screen_width == "800" && screen_height == "600")
alright that worked, thanks, everything is all good now . Dumb mistake on my part, should of known that.

Quote:
Originally Posted by logic ali View Post
The problem is very simple and obvious, but 'fixing' it won't really fix anything.
The real answer is to fix your CSS to cope with different screen resolutions, so I recommend that you ask in a CSS forum.
Wrong, fixing it has fixed everything.
__________________

Please login or register to view this content. Registration is FREE
Slick Nick is offline
Reply With Quote
View Public Profile
 
Old 01-06-2007, 12:12 AM Re: Messed up script
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by Slick Nick View Post
alright that worked, thanks, everything is all good now . Dumb mistake on my part, should of known that.



Wrong, fixing it has fixed everything.
So what happens if the page is loaded by a browser with JavaScript disabled?
logic ali is offline
Reply With Quote
View Public Profile
 
Old 01-06-2007, 01:17 AM Re: Messed up script
Oneway's Avatar
Skilled Talker

Posts: 71
Trades: 0
Or if the browser window is smaller then the screen dimensions?
Oneway is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Messed up script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29603 seconds with 12 queries