FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Screen resoltion detection script not working??

 


flatliner
Can any1 see whats wrong with this javascript? it keeps out putting the last if() even when its not ture

Code:


if ((screen.width>=800) && (screen.height>=600) && (screen.width<1024) && (screen.height<768))
{document.write('<link rel="stylesheet" href="screen_small.css" type="text/css">')}

if ((screen.width>=1024) && (screen.height>=768) && (screen.width<1280) && (screen.height<1024))
{document.write('<link rel="stylesheet" href="screen_medium.css" type="text/css">')}

if ((screen.width>=1280) && (screen.height>=1024))
{document.write('<link rel="stylesheet" href="screen_large.css" type="text/css">')}
carlospro7
consider making them if else statements.

Code:
if (<expr>) { <statement> }
else {
if (<expr>) { <statement> }
else if (<expr>) { <statement> }
}


see if that fixes your problem.


Last edited by carlospro7 on Thu Feb 14, 2008 7:09 pm; edited 1 time in total
flatliner
Thanks for your reply, but I actually figured it out, nothing wrong with the code, but the program I was using to switch between screen resolutions wasnt regstering the new dimnientions. Thanks anyway
carlospro7
flatliner wrote:
Thanks for your reply, but I actually figured it out, nothing wrong with the code, but the program I was using to switch between screen resolutions wasnt regstering the new dimnientions. Thanks anyway


I figured it might be something else.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.