aptana3 - Hiding JavaScript from displaying in old browsers -


i trying learn javascript book. first chapter of book says use following format support older browsers don't support js. simple, uses html comment tag hide script browsers don't support js. doubt here code works fine me in browsers showing error in aptana studio 3. understand error due aptana considering "<" relational operator how can resolve error?

<script>     <!--         //some js code on here...     //--> </script> 

error(syntax error: unexpected token) coming @ :

<!-- 

i'm aware not answer question directly, truth not need done. if browser not know how interpret javascript, browsers ignore code anyway. furthermore, adding <!-- // --> can dangerous following reasons, given matt kruse:

  • within xhtml documents, source hidden browsers , rendered useless
  • it not allowed within html comments, decrement operations in script invalid

for more detailed explanation, recommend check out this documentation best practices javascript , this question explains why using html comments in javascript bad practice.

if whatever reason still want show content user if have javascript disabled (or can't run because of old browser), use <noscript> tag

if deadset on commenting out javascript use code snippet instead, shouldn't give error:

//<!--  //--> 

if have more questions feel free ask.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -