<无脚本>无法在 Opera 11 中工作?无脚本>
我正在测试我的 noscript 标签,它在禁用 javascript 时显示内容,这适用于 Safari、Chrome、Firefox、Camino、IE6、IE7、IE8、IE9,基本上除了 Opera 之外的所有版本(我正在运行版本 11,不确定它是否独立)到那个版本)。
在 Opera 11 中没有显示任何内容...是否不支持 noscript 标签?还有什么选择呢?
没什么奇怪的:
<noscript>Please enable JavaScript.</noscript>
位于 body 标签之间。
<html>
<body>
<script>alert('Hello World');</script>
<noscript>Hello World!</noscript>
</body>
</html>
I am testing my noscript tags which display content when javascript is disabled, this works in Safari, Chrome, Firefox, Camino, IE6, IE7, IE8, IE9, basically everything but Opera (I'm running version 11, not sure if its isolated to that version).
In Opera 11 nothing is displayed... is the noscript tag not supported? and what is the alternative?
Nothing surprising:
<noscript>Please enable JavaScript.</noscript>
Located between the body tags.
<html>
<body>
<script>alert('Hello World');</script>
<noscript>Hello World!</noscript>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您确定在 Opera 中禁用了 javascript:
菜单 >>设置>>首选项>>内容>>取消选择“启用 Javascript”
如果是这样,请在此处发布整个文件的内容。
编辑
直到他们修复版本11中的这个错误,我认为很快就会发生,你可以尝试这个:
你基本上使用javascript来显示隐藏无脚本消息的css,但是如果禁用了javascript,那么就会有无法显示 css,因此会显示该消息。
Are you sure you disabled javascript in Opera:
Menu >> Settings >> Preferences >> Content >> Deselect "Enable Javascript"
If so, then post the contents of your entire file here.
EDIT
Until they fix this bug in version 11 which I reckon will happen shortly you can try this:
You are basically using javascript to show css which hides the no script message, but if javascript is disabled then there is no way that css can be displayed hence the message will show.
呃,是的。我们(如在 Opera 中)破坏了 Opera 11 中的
。已知错误。
Uh, yeah. We (as in Opera) broke
<noscript>
in Opera 11. Known bug.的实现存在缺陷且不一致,因此不推荐。你最好这样做:
然后你可以使用 JavaScript 在页面加载时隐藏任何带有“noscript”类的内容。禁用 JavaScript 的人会看到该消息,因为它不会被隐藏。
Implementation of
<noscript>
is buggy and inconsistent and not recommended. You'd be better off doing something like:You can then use JavaScript to hide anything with a class of "noscript" on page load. People with JavaScript disabled will see the message because it won't be hidden.
嗯。我将元刷新封装在 noscript 中,这样,如果页面中的某些元素无法通过 JavaScript 重新加载,则页面可以自动重新加载。我看不到任何像涉及隐藏 CSS 元素的 hack 那样的替代方案。我最初的想法可能是设置一个元刷新标头,但如果 javascript 可以执行,则覆盖它以根本不刷新,但我看不到 javascript 重新定义页面刷新时间的任何方法。
Hrm. I had wrapped a meta refresh within a noscript, so that a page could automatically reload if a certain set of elements within it couldn't reload via javascript. I can't see any alternative like the hack involving hiding CSS elements. My original thought was perhaps to set a meta refresh header, but override that to not refresh at all if the javascript could execute, but I can't see any ways for javascript to redefine the page refresh time.
试试这个
try this
不建议使用
noscript
元素。如果脚本被部分阻止(例如,通过公司防火墙或 NoScript 扩展,或者只是临时的 DNS 故障),它将无法工作。构建在有效的东西上。
The
noscript
element isn't recommended. It won't work if scripts are partially blocked (e.g. by a corporate firewall or the NoScript extension, or just a temporary DNS failure).Build on things that work instead.
这对我来说效果很好...(在 IE、Opera 和 FireFox 中测试)
JavaScript 立即运行,因此 noscript 消息永远不会出现。
这个想法是将 JavaScript 代码紧跟在 noscript 的开始标记(在本例中为段落标记)之后。
This works well for me... (Tested in IE, Opera, and FireFox)
The JavaScript runs immediately so the noscript message never appears.
The idea is to place the JavaScript code immediately following the noscript's opening tag, in this case the paragraph tags.