在XHTML中的noscript替代方案? [英] noscript alternative in XHTML?
问题描述
< noscript>< link href =css / stylenojs.css =stylesheettype =text / css/>< / noscript>
在XHTML Transitional或Strict文档中是否存在兼容的方法?
你给的例子在HTML和XHTML中都是无效的。没有当前的建议提供了一种方法来包含样式表,除非启用了脚本。
通常,您应该避免< ; NOSCRIPT>
。从有用的东西开始,然后构建它。 p>
在这种情况下,您可以为非JS客户端编写样式表,然后:
<身体GT;
< script type =text / javascript> document.body.className + ='js';< / script>
...并且包含额外的特定于JS的规则集:
body.js foo {
}
或者,您可以执行以下操作:
< link href =css / stylenojs.css rel =stylesheettype =text / cssid =nojscss/>
和
var nojscss = document.getElementById('nojscss');
nojscss.parentNode.removeChild(nojscss);
In HTML I could do:
<noscript><link href="css/stylenojs.css" rel="stylesheet" type="text/css" /></noscript>
Is there some compliant way to do so in XHTML Transitional or Strict documents?
The example you give is invalid in HTML as well as XHTML. No current recommendation provides a way to include a stylesheet unless scripting is enabled.
In general, you should avoid <noscript>
. Start with something that works, and then build on it.
In this case, you could write your stylesheet for non-JS clients, then:
<body>
<script type="text/javascript">document.body.className += ' js';</script>
… and include additional rule-sets specific to JS being enabled with:
body.js foo {
}
Alternatively, you could do something like:
<link href="css/stylenojs.css" rel="stylesheet" type="text/css" id="nojscss" />
and
var nojscss = document.getElementById('nojscss');
nojscss.parentNode.removeChild(nojscss);
这篇关于在XHTML中的noscript替代方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!