javascript| Tutorial
Use JavaScript to hide JavaScript from old browsers
For JavaScript beginners, they often forget to hide JavaScript code in old browsers, such as Netscape Navigator 1.12. You might ask why you want to hide it? The simple reason is that the old browser does not support JavaScript. If you don't do the right thing, the old browser will display your JavaScript source code, just like HTML, so you have to hide the JavaScript. Specifically, you can use some HTML statements to easily hide JavaScript from the old browser.
The specific code is as follows:
<script language= "JavaScript" >
<!--alert ("JavaScript is running!");
--> </SCRIPT>
JavaScript-enabled browsers will interpret this code, and the old browser will only treat it as HTML, and it has been commented, so it has been able to hide JavaScript code. You may want to add some text to the <NOSCRIPT> tab, which allows non-JavaScript users to see what they are missing:
<noscript>this'll only show up in older Non-javascript capable browsers</noscript>
In fact, there are very few browsers that do not support JavaScript, even if there are few people using that kind of browser, which can be ignored during normal production. But then again, for a programmer, it's important to develop good programming habits, and of course it's from small things.