JavaScript<! - // - >是必要的? [英] JavaScript <!-- //--> are required?

查看:80
本文介绍了JavaScript<! - // - >是必要的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想问一下标题所说的内容。在HTML脚本标记中需要以下字符串?

 <! -  
// - >

如果我不使用它们会发生什么?

< script> 元素的浏览器(即Netscape 1和朋友)。 (提示:你没有)。



如果你不使用它们,并且浏览器那么旧(太旧甚至无法应付HTTP主机使用虚拟主机的网站所需的标题)尝试访问该网站,然后将< script> 元素的内容视为要显示的文本。 / p>

进一步阅读:评论和CDATA:脚本的神秘历史和style in HTML


I just like to ask what the title says. The following string required into HTML script tags?

<!--
//-->

If I don't use them what would happen?

解决方案

Not unless you are targeting browsers that predate the <script> element (i.e. Netscape 1 and friends). (Hint: You aren't).

If you don't use them, and a browser that old (so old it can't even cope with the HTTP Host header which is needed for sites that use virtual hosts) tries to access the site, then the content of the <script> element will be treated as text to be displayed.

Further reading: Comments and CDATA: The mysterious history of script and style in HTML

这篇关于JavaScript&lt;! - // - &gt;是必要的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆