How do I create an alternative to Javascript?

I’m coding this new left navigation menu for a new website site, and I want to be able to have the navigation show if the visitor has Javascript turned off. Unfortunately the menu has sub-menus that don’t show if the user doesn’t have Javascript turned on. How do I create an alternative section to accommodate this?

I got this question from Kelly who was putting together a website using a a funky Javascript menu and ran into an accessibility issue if the user’s browser doesn’t run Javascript (or if the user opts to run NoScript or some other blocking plugin)

The answer is really quite simple. Even piece of Javascript on a web page has the option of being following by a NOSCRIPT section that is executed by the browser if Javascript is not enabled. Here’s an example of how it works:

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

So, the browser will actually execute one of the 2 sections, if you have Javascript enabled, it will perform the <script> section, otherwise it will execute the <noscript> section. But you get some sort of “Hello World” message regardless of whether you are using Javascript or not.

Hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.