It's so hard to search for symbols in Google, so I ask here instead.
<!--
looks like a comment for me, but it doesn't work like html. Or it's a one line comment just like //
?
What is the purpose and benefit of using this? Thanks
sample code :
<script type="text/javascript">
<!--
alert("example");
//-->
</script>
It's an old method of hiding JavaScript from browsers that would treat the text node of a script
element as normal text (and display your code).
Douglas Crockford recommends you don't use it anymore.
Do not use the
<!-- //-->
hack with scripts. It was intended to prevent scripts from showing up as text on the first generation browsers Netscape 1 and Mosaic. It has not been necessary for many years.<!-- //-->
is supposed to signal an HTML comment. Comments should be ignored, not compiled and executed. Also, HTML comments are not to include--
, so a script that decrements has an HTML error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With