Jiasheng Posted March 12, 2006 Share Posted March 12, 2006 <script language="JavaScript"><!--if (navigator.appVersion.substring(0,1) >= 4) { var width = window.innerWidth; if (width > 900) { document.write("<link href='http://www.lomontimt.com/quotes/style1.css' rel='stylesheet' type='text/css'>"); } else { document.write("<link href='http://www.lomontimt.com/quotes/style2.css' rel='stylesheet' type='text/css'>"); }}else { document.write("<link href='http://www.lomontimt.com/quotes/style1.css' rel='stylesheet' type='text/css'>"); }//--></script> I set up the above Javascript to switch between two style sheets. User with screen resolution 1024x768 will be presented with style1.css, and those with smaller resolution will be presented with style2.css. But it seems that the parameter window.innerWidth is not working. Style sheet 2 is presented all the times regardless of the screen resolution. Appreciate very much if anyone could help me! Link to comment Share on other sites More sharing options...
scott100 Posted March 12, 2006 Share Posted March 12, 2006 try screen.width <script language="JavaScript"><!--if (navigator.appVersion.substring(0,1) >= 4) { var width = screen.width; alert(width); if (width > 900) { document.write("<link href='http://www.lomontimt.com/quotes/style1.css' rel='stylesheet' type='text/css'>"); } else { document.write("<link href='http://www.lomontimt.com/quotes/style2.css' rel='stylesheet' type='text/css'>"); }}else { document.write("<link href='http://www.lomontimt.com/quotes/style1.css' rel='stylesheet' type='text/css'>"); }//--></script> Link to comment Share on other sites More sharing options...
Jiasheng Posted March 12, 2006 Author Share Posted March 12, 2006 Yes, it works! Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now