Quote:
Originally Posted by sunfighter
Javascript can not tell you if js is off, because it's not working.
What you want to do is show the static image you want seen with js off. Then in javascript turn the image off and run your scroller.
|
You’re close with your thinking but not quite there. The actual problem is that the HTML is styled (through CSS) with the assumption that JS is present/active even though it might be
not. For example, in order to hide content initially which is faded in with JS later on, people apply
display: none to that content without realizing that it will always be hidden and never fade in when JS is not present.
The ultimate solution to this is to make JavaScript assign a class to an element in the document and only hide contents if that class is present. If JS is not available the class won’t be added and the content won’t be hidden by default. Makes sense?
I’m usually adding a class to the body and use that as CSS selector:
Code:
document.getElementsByTagName('body')[0].className = 'jsenabled';
// or in jQuery
$('body').addClass('jsenabled');
Code:
…
<body>
<div id="example"></div>
</body>
Code:
#example {…}
.jsenabled #example {display: none;}