• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Combining JavaScript and HTML > Hiding JavaScript from Older Browser...

Hiding JavaScript from Older Browsers

Browsers prior to Netscape Navigator 2.0 cannot run JavaScript at all, and if they come across JavaScript in a Web page, it causes them to generate some really ugly errors. To avoid the possibility of such errors, hide any script you place on the page by putting HTML comment tags inside the <script> block. This is quick and simple to add, and even though older browsers are pretty rare nowadays, inserting the comment tags into your HTML template so that they appear on every Web page that contains JavaScript is still worthwhile.

These comment tags are easy to add. Inside the <script> tags, insert another pair of tags, <!-- and -->. All the code you write goes in between these tags and is then ignored by any browser that doesn't understand what the <script> tags mean.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint