Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  26] [ 3]  / answers: 1 / hits: 19417  / 15 Years ago, fri, october 16, 2009, 12:00:00

I'm trying to accommodate users without JavaScript. (By the way, is it worth the effort nowadays?)



In one HTML file I'd like part of it execute if scripts are on, and another part if scripts are OFF.



The <noscript> tag lets me do the former, but how to achieve the latter? How can I mark a part of HTML so that it is not parsed by browser if scripts are off?


More From » html

 Answers
94

here's a video tutorial on how this can be done with jQuery: http://screenr.com/ya7



Code:



<body class=noscript>
<script>
$('body').removeClass('noscript');
</script>
</body>


And then just hide the relevant elements under body.noscript accordingly.



edit
However, JQuery might be bloated for a small fix like this one, so I suggest Zauber Paracelsus' answer since it does not require JQuery.


[#98499] Monday, October 12, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leog

Total Points: 225
Total Questions: 113
Total Answers: 118

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;