<noscript> not working in Opera 11?

你说的曾经没有我的故事 提交于 2019-12-05 09:54:46

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.

gsnedders

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

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.

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

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

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.

Glen

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!