How to handle JS if browser doesn’t support JavaScript ?

January 29, 2025 No Comments » Hits : 388





JS Script :

<html>
<body>
<script type="text/javascript">
<!--
document.getElementById("demo").innerHTML=Date();
//-->
</script>
</body>
</html>

Explanation :

  • All modern browsers supports JS.
  • If any old browser that do not support JavaScript will show JS Script as its page content.
  • In order to handle this situation JavaScript Standard provides us easy way of hiding JS code.
  • HTML Comment tag is used to hide JS code.

How to Comment Code ?

  1. Add an HTML comment tag <!- before the first JavaScript statement
  2. Add a -> (end of comment) after the last JavaScript statement.
  3. The two forward slashes at the end of comment line (//) is the JavaScript comment symbol.
  4. This prevents JavaScript from executing the -> tag.

Incoming search terms: