Loading CSS when no Javascript Present

liunx

Guest
Wasnt sure if this was css related of Javascript or HTML realy... but Im trying to use:

<script type="javascript"></script>
<noscript><link rel="stylesheet" type="text/css" href=http://www.webdeveloper.com/forum/archive/index.php/"/noscript.css"></noscript>

Anyway W3C doesnt like this and closes the head before the noscript. So im wondering how do i get it so that when there is no javascript is present that it loads another style sheet.

By the way it appears to work in the browsers so its a little frustrating that w3c doesnt like it.The rules are pretty simple, the NOSCRIPT element isn't allowed in the document's head. Try something like <link href=http://www.webdeveloper.com/forum/archive/index.php/"/noscript.css" rel="stylesheet" title="JavaScript free" type="text/css">
<script type="text/javascript">
if (document.getElementsByTagName) onload = function () {
var e, i = 0;
while (e = document.getElementsByTagName ('LINK')[i++]) {if (e.title && e.title == 'JavaScript free') e.disabled = true}
}
</script>That script seems to semi work.... as in the sense that when no JS is present the CSS loads, but that script seems to disable other CSS sheets that are supposed to always be loaded.It should disable only those sheets with a title of "JavaScript free". Can you post athe URL of a page where this is not the case?A solution Ive been given is as follows:

<script type="text/javascript">document.write("<!"+"--");</script>
<link rel="stylesheet" type="text/css" href=http://www.webdeveloper.com/forum/archive/index.php/"http://email.goeshere.com/theme/noscript.css">
<script type="text/javascript">document.write("--"+">");</script>

So simply when JS is presntr the css gets commented out. Really simple!
 
Back
Top