admin管理员组文章数量:1244243
Does anyone still use the old
<!-- hide JS from old browsers -->
trick?
As I recall, this was targeted at people who used Netscape, or IE4.
I just checked out our stats and in the last month we had more people visit the site using "Playstation Portable " (4 visits) as their user agent than we had using Netscape (1 visit).
Is there any point in me even having the "hide" thing in my javascript?
Does anyone still use the old
<!-- hide JS from old browsers -->
trick?
As I recall, this was targeted at people who used Netscape, or IE4.
I just checked out our stats and in the last month we had more people visit the site using "Playstation Portable " (4 visits) as their user agent than we had using Netscape (1 visit).
Is there any point in me even having the "hide" thing in my javascript?
Share Improve this question asked Apr 20, 2011 at 4:35 nedludnedlud 1,8324 gold badges19 silver badges33 bronze badges4 Answers
Reset to default 13No, you no longer need to do that.
Crockford also says...
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 ment. Comments should be ignored, not piled and executed. Also, HTML ments are not to include--
, so a script that decrements has an HTML error.
No. {insert extra chars here to meet limit for SO}
The way I figure it, if you're designing an application with which one of the main selling points is javascript-based interactivity, there's no point in catering to older browsers.
Still, it's important to know the specific goals of your product. You need to know who you're targeting and make an informed decision as to whether or not it's worth it.
In any case, you should make an attempt to discover whether or not a browser has javascript enabled, and if not, inform them of why your site will not work.
Yes, and you should, too. Drupal does it this way:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
...
//--><!]]>
</script>
本文标签: javascriptDoes anyone still hide JS from old browsersStack Overflow
版权声明:本文标题:javascript - Does anyone still hide JS from old browsers? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740178727a2236920.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论