<无脚本>无法在 Opera 11 中工作?

发布于 2024-10-09 01:06:20 字数 504 浏览 0 评论 0原文

我正在测试我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

羁客 2024-10-16 01:06:20

您确定在 Opera 中禁用了 javascript:

菜单 >>设置>>首选项>>内容>>取消选择“启用 Javascript”

如果是这样,请在此处发布整个文件的内容。

编辑


直到他们修复版本11中的这个错误,我认为很快就会发生,你可以尝试这个:

<script type="text/javascript">
<!--

    document.write("<style type='text/css'>.noScript { display: none; }</style>");

//-->
</script>

<span class="noScript">Please enable javascript in your browser.</span>

你基本上使用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:

<script type="text/javascript">
<!--

    document.write("<style type='text/css'>.noScript { display: none; }</style>");

//-->
</script>

<span class="noScript">Please enable javascript in your browser.</span>

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.

情定在深秋 2024-10-16 01:06:20

呃,是的。我们(如在 Opera 中)破坏了 Opera 11 中的 。已知错误。

Uh, yeah. We (as in Opera) broke <noscript> in Opera 11. Known bug.

横笛休吹塞上声 2024-10-16 01:06:20

的实现存在缺陷且不一致,因此不推荐。你最好这样做:

<span class="noscript">Please enable JavaScript.</span>

然后你可以使用 JavaScript 在页面加载时隐藏任何带有“noscript”类的内容。禁用 JavaScript 的人会看到该消息,因为它不会被隐藏。

Implementation of <noscript> is buggy and inconsistent and not recommended. You'd be better off doing something like:

<span class="noscript">Please enable JavaScript.</span>

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.

很快妥协 2024-10-16 01:06:20

嗯。我将元刷新封装在 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.

ˇ宁静的妩媚 2024-10-16 01:06:20

试试这个

<span class="noscript"></span>
 <noscript>Please enable JavaScript.</noscript>

try this

<span class="noscript"></span>
 <noscript>Please enable JavaScript.</noscript>
忆依然 2024-10-16 01:06:20

不建议使用 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.

荒人说梦 2024-10-16 01:06:20

这对我来说效果很好...(在 IE、Opera 和 FireFox 中测试)

<p id="js_disabled">
<script type="text/javascript">
  document.getElementById('js_disabled').style.display = 'none';
</script>
  Javascript is disabled or not supported by your browser.<br/>
  Javascript must be enabled...
</p>

JavaScript 立即运行,因此 noscript 消息永远不会出现。

这个想法是将 JavaScript 代码紧跟在 noscript 的开始标记(在本例中为段落标记)之后。

This works well for me... (Tested in IE, Opera, and FireFox)

<p id="js_disabled">
<script type="text/javascript">
  document.getElementById('js_disabled').style.display = 'none';
</script>
  Javascript is disabled or not supported by your browser.<br/>
  Javascript must be enabled...
</p>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文