<noscript> not working in Opera 11?
Asked Answered
G

7

5

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>
Guiana answered 24/12, 2010 at 7:56 Comment(2)
Any idea when this bug WILL be fixed? I'm having to access a particular site my wife uses in her teaching with (ugh!) IE.Deanndeanna
I wouldn't get my hopes up, Opera has problems with noscript tag for years. Opera 9.64 and Opera 10 display the contents of noscript tag even if javascript is turned on, Opera 11 doesn't display it at all.Caravansary
S
8

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.

Sivas answered 24/12, 2010 at 8:3 Comment(3)
Yes it is disabled... try it for yourself:Guiana
@Guiana ha I tried it in the previous version, just upgraded to version 11 and like you nothing shows. Guess something's wrong with the latest.Sivas
Yeah because i did recall it worked in previous opera versions... must be a bug.Guiana
W
6

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

Wynnie answered 26/12, 2010 at 21:49 Comment(1)
(It should be working fine in pretty much all earlier versions, and will again at some point in the future..)Schaaff
T
1

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.

Tea answered 24/12, 2010 at 18:16 Comment(0)
M
1

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.

Megganmeggi answered 5/2, 2011 at 18:3 Comment(0)
S
0

try this

<span class="noscript"></span>
 <noscript>Please enable JavaScript.</noscript>
Snooze answered 24/12, 2010 at 8:7 Comment(0)
F
0

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.

Froma answered 24/12, 2010 at 18:12 Comment(0)
B
0

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.

Bassist answered 1/6, 2011 at 19:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.