Lesson 1: Hiding Your Script from Old Browsers



In order for us to show you actual HTML & JavaScript code while you read the instructions we are going to make a simple change.

Code that is written between the < ??????? > greater and less than symbols will be shown as [ ??????? ]. This is only the case for showing actual code on the web page. Remember that when you are actually starting to write HTML and JavaScript to use the greater and less than symbols in your source code.

The internet is a global phenomenon. Millions of people across the globe access its vast wealth of information. If you want people to be able to access your site you have to create a site that adapts to the visitor's browser settings and configuration. Some browsers can only read HTML and get confused when they see JavaScript. The resulting confusion could ruin the look and feel of your web site.

Therefore it is important to be able to hid JavaScript from any browsers that aren't capable of interperating it. First, you have to tell the browser that you are going to use JavaSctript as a language. Like this:



[ SCRIPT LANGUAGE="JavaScript" ]


By the way, JavaScript is case-sensitive so you have to type it exactly as you see it. Next you are going to use one of the possible actions a script can ask a document to perform. A built-in function that detects and tells the user what browser version and browser name they are using like this:



document.write ("This browser is version " + navigator.appVersion)
document.write (" of " + navigator.appName + ".")


As you can see I have already included this simple script on the page below so you can see its result.



If you are shaking with excitement and your mouth is drooling with anticipation don't worry, millions of other users who have visited our site also reported the same phenomenon. Just click on Lesson 2 to enter a higher state of consciousness!






If you have comments on these pages, send an e-mail.

To return to my homepage, Click here.