1

The <noscript> tag can be used to display a message if the user has scripting turned off - but is there any way in which it can be used to contain a conditional (html) statement, or more complicated coding?

Edit: Sorry, perhaps I wasn't clear; I have nothing against the noscript tag itself - but was wondering about the upward limitations of its usage? As far as I have seen, its usage has been merely to tell people to turn scripting on. I'm thinking about potential in terms of accessibility.

4

3 回答 3

4

有什么问题<noscript>?它可以包含您想要的任何内容。从整个布局到<style>元素再到大胖警告信息。

显然,您不能在其中使用 JavaScript,但除此之外,您可以做任何事情。

于 2012-10-14T21:22:38.197 回答
2

坚持使用 noscript 标签,因为它是解决问题的标准方法。搜索引擎知道如何处理它,屏幕阅读器知道如何处理它,关闭 javascript 的人会看到一个花哨的警告/消息(带有一些 CSS)。

顺便说一句:如果脚本也被关闭,你就不能做任何花哨的事情。

在 noscript 标签中,您可以使用 body 标签中直接允许的所有元素。有关详细信息,请参阅您提供的链接。

于 2012-10-14T21:27:13.453 回答
2

你可以这样做:

<div id="removeIfJS">Sorry, but javascript is disabled</div>
<script>
 var sorry = document.getElementById("removeIfJS");
 sorry.parentNode.removeChild(sorry);
</script>
于 2012-10-14T21:20:04.813 回答