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

Posts: 217
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?
__________________
Helm Games
Slick Nick is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-03-2007, 11:59 PM Re: Messed up script
logic ali's Avatar
Skilled Talker

Posts: 86
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:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
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
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.
__________________
Helm Games
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
Skilled Talker

Posts: 86
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: 73
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

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

vB 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.32924 seconds with 12 queries