问题描述
在上,它显示了htis代码:
On the W3 tutorial, it shows htis code:
<html>
<body>
<script type="text/javascript">
<!--
document.getElementById("demo").innerHTML=Date();
//-->
</script>
</body>
</html>
然后它说:
这对我没有意义。我以为整件事都被评论了。
This doesn't make sense to me. I thought the whole thing got commented out.
推荐答案
首先,W3Schools 没有与W3有关。在人们开始抱怨之前,他们的教程非常糟糕,他们混淆的名字意味着他们以某种方式连接到W3,但实际上他们并没有。
First of all, W3Schools has nothing to do with W3. Their tutorials were pretty horrible before people started complaining and their confusing name implies that they are somehow connected to W3, but in reality they aren't.
其次,这个不再需要方法。没有使用过的浏览器不干净地支持JS( links
, lynx
等等,JS没有麻烦任何代码。)
Second of all, this method is not needed anymore. There are no used browsers that don't support JS cleanly (links
, lynx
, etc. have no troubles with JS code whatsoever).
话虽这么说,代码应该这样做:
That being said, the code is supposed to do this:
<!--
I am a HTML comment
-->
<!--
If I am placed in a JS block, the web browser should ignore me
alert('and me');
-->
<!--
If you comment out the HTML comment ending tag, apparently
the browser will treat the comment as JS code *only*
if the browser supports JS.
//-->
这篇关于为什么非Javascript浏览器中的这个Javascript代码有额外的评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!