Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




The JavaScript FAQ
Prev Home Next

Hiding JS code from old browsers

Question: How do I hide JS code from old browsers that do not support JavaScript?

Answer: To prevent old browsers from displaying your JS code, do the following:

  1. Immediately after the opening <script> tag, put a one-line HTML-style comment without the closing characters, so that the first two lines of your script would look like this:
    <script language="JavaScript">
  2. At the end of your script, put the following two lines:
Thus, your HTML file will contain the following fragment:
<script language="JavaScript">
Here you put your JS code.
Old browsers will treat it
as an HTML comment.

Old browsers will treat your JS code as one long HTML comment. On the other hand, new JavaScript-aware browsers will normally interpret JS code between the tags <script> and </script> (the first and last lines of your JS code will be treated by the JavaScript interpreter as one-line comments). Copyright © 1999-2006, Alexei Kourbatov

The JavaScript FAQ
Prev Home Next

  Mirrored with kind permission of Alexei Kourbatov Design by Interspire