I have some elements with display:none; in the CSS and some jQuery that will fade them in on a delay.
How can I handle browsers that have javascript turned off? Is there some way of using <noscript> to change those elements display values?
You can't set a CSS value without a script, but you could have the default as being the visible state, and the first thing you do in the script is immediately set the elements to the non-visible state before fading them on.
You could also look at CSS Animations http://www.w3.org/TR/css3-animations/ which don't require JavaScript, but they do need a modern-ish browser http://caniuse.com/css-animation
$(document).ready function then running my animation. I thought this would flicker but I guess I'm not hiding many elements. Need to test in IE yet though.If you use modernizr, it will insert the class js into your <html> tag (if Javascript is running of course), and by having the html structure proposed by HTML5 boilerpate:
<!--[if lt IE 7 ]> <html class="no-js ie6 ie"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7 ie"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8 ie"> <![endif]-->
<!--[if IE 9 ]> <html class="no-js ie9 ie"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html class="no-js">
<!--<![endif]-->
By default you will have <html class="no-js">, and you could potentially have certain things (that you are worried about being exposed that normally JS hides) in your css to by default use it as a parent selector to hide it.
.no-js .whatever, .no-js .someOtherStuff { display: none; } <!-- just an example -->
.no-js to show elements that are faded in at a certain time anyway was the best way around the javascript disabled issue. Thanks!Set the css property to display the elements and then if javascript is enabled, use javascript to close / hide the elements. However, I don't like doing this because the number of users with javascript enabled far out weighs users without javascript. You don't want to force the bulk of your users to wait for the page to load all the elements and then hide them when they have already had a peak at the content.
You want the users that are actually using your webpage the way you designed it, to have the best experience they can. The web is so feature rich in javascript, jquery and other libraries that the users without javascript are used to not getting the experience the web developer intended. If I feel that I really have a soft spot for the users without javascript, I will redirect them to to a static page. Them and the web crawlers will have fun together.
noscripttag?display:block;if there is no javascript enabled?element.style.display = 'none', as using jQuery will make the elements visible for a moment until jQuery is loaded etc.