|
|
|
|
![]() ![]() |
May 8 2008, 12:26 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 205 Joined: 14-March 06 From: Vermont or Boston (USA) Member No.: 20,077 |
I am trying to use javascript to include a stylesheet depending on the user's resolution.
The HTML CODE <head> <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" /> <?php if ($my->id) { initEditor(); } ?> <?php mosShowHead(); ?> <noscript><link rel="stylesheet" type="text/css" href="http://www.highimpactart.org/templates/_HighImpactArt_/1024/1024.css" /></noscript> <script type="text/javascript"> if (screen.width>=1050) { document.write('<link rel="stylesheet" type="text/css" href="http://www.highimpactart.org/templates/_HighImpactArt_/1280/1280.css" />'); } </script> </head> I'm running into two problems. 2) The <noscript> tags cause all sorts of validation errors. From what I've read it seems as though the <noscript> tag is not allowed within the <head> section -- is this correct? Could the same thing be accomplished just putting the default stylesheet above the javascript? The 1280 stylesheet has the same exact classes as the 1024 stylesheet, so would that over ride it? 3) Ie: CODE <script type="text/javascript">/*<![CDATA[*/ YourJavaScriptCodeHere /*]]>*/</script> Thank you for your time. This post has been edited by truefusion: May 8 2008, 10:01 PM |
|
|
|
May 8 2008, 07:21 AM
Post
#2
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,056 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
2) The <noscript> tags cause all sorts of validation errors. From what I've read it seems as though the <noscript> tag is not allowed within the <head> section -- is this correct? Could the same thing be accomplished just putting the default stylesheet above the javascript? The 1280 stylesheet has the same exact classes as the 1024 stylesheet, so would that over ride it? The noscript element can only go in the body, as either an inline or block level element. Stylesheets do cascade, meaning that a second stylesheet will overwrite the first. You could therefore always include the 1024 stylesheet, and just use JS to put in the 1280 stylesheet if necessary. 3) Ie: <script type="text/javascript">/*<![CDATA[*/ YourJavaScriptCodeHere /*]]>*/</script> Thank you for your time, ~Paolo You shouldn't have the /* in your code there. It should just be: CODE <script type="text/javascript">
<![CDATA[ Some JS here... ]]> </script> |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 26th July 2008 - 02:43 PM |