Subscribe in a reader

Go Back   Webforumz.com > Resources > FAQ > (X)HTML & CSS

Notices




Display text if user has javascript off, but not when it's turned on?

Display text if user has javascript off, but not when it's turned on?

Published: Feb 1st, 2008
Need a way of telling people to turn on javascript but only to those who need telling?



This is a very easy to solve problem. There is actually a html tag which does exactly that. It's called the <noscript> tag. The noscript tag is used to define alternate content, usually text, when a script does not execute. Please note however, if your script does not run, but the browser supports javascript, then the text in the <noscript> tag will not display either.
To use the <noscript> element, place it after your <script> tag.

<script type="text/javascript"> 
<!--
document.write("Hello World!")
//-->
</script>
<noscript> Your browser does not support JavaScript!</noscript>

Remember, you should wrap the script in a HTML comment, because older browsers which do not recognize the <script> tag would display the code on the page, but because of the HTML comment they would take the script and place it inside a HTML comment, so it will not actually display.



Members's Comments & Rating
Posted at Jun 26th, 2008 by moojoo
<noscript> can also be used in correct locations within your document to show a xhtml.css fall back to a js provided content area. I implemented this partially on us.iams.com, if you look at the left flash element and disable js or uninstall flash it will degrade 100% with absolutely no visual difference other than the animation loss.
Page 1 of 1

Author

Jack Franklin
Jack is 15 years old and lives happily in Cornwall, England. Web Design is his passion and he works using xHTML, CSS and PHP to code his websites, with the odd bit of Javascript now and then. In his spare time, Jack enjoys playing Football, rugby, tennis and snooker (but not all at the same time). Jack can be contacted through his online E-Portfolio.

View more articles from Jack Franklin

All times are GMT. The time now is 05:21.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42