当JavaScript停用时,如何显示不同的内容? [英] How can I show different content when JavaScript is disabled?
问题描述
当JavaScript停用时,我需要显示完全不同的内容。我知道我可以使用< noscript>
标签...但是当JavaScript被禁用时,如何隐藏页面的其余部分?
感谢。
这里是另一种解决方案:
在您的正常样式表下方有:
< link rel =stylesheethref =jsdisabled.css />
< script type =text / javascript>
document.write('< link rel =stylesheethref =jsenabled.css/>');
< / script>
jsenabled.css会有:
#content {display:block; }
而jsdisabled.css会有:
#content {display:none; }
虽然下面的解决方案无效, 您可以放置一些风格标签隐藏其余内容 ie: 我喜欢使用这种方法,因为当javascript启用时,不会使页面闪烁。 p> I need to show COMPLETELY different content when JavaScript is disabled. I know I can use Thanks. here is another solution: inside your head below your normal stylesheet have: that jsenabled.css would have: while jsdisabled.css would have: although the solution below works it does not validate inside your noscript tag you can put some style tag that hides the rest of your content ie: I like using this method because it doesn't make the page flash when javascript is enabled. 这篇关于当JavaScript停用时,如何显示不同的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
< noscript>
< style type =text / css>
#content {display:none; }
< / style>
没有js内容来这里。
< / noscript>
< div id =content>
的内容在这里。
< / div>
<noscript>
tag... but how can I hide the rest of the page when JavaScript is disabled?<link rel="stylesheet" href="jsdisabled.css" />
<script type="text/javascript">
document.write('<link rel="stylesheet" href="jsenabled.css" />');
</script>
#content { display:block; }
#content { display:none; }
<noscript>
<style type="text/css">
#content { display:none; }
</style>
no js content goes here.
</noscript>
<div id="content">
content here.
</div>