cappuccino
cappuccino

Reputation: 2185

<noscript> not working in Opera 11?

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>

Upvotes: 5

Views: 3255

Answers (7)

Glen
Glen

Reputation: 11

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.

Upvotes: 0

TimC
TimC

Reputation: 11

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.

Upvotes: 1

gsnedders
gsnedders

Reputation: 5692

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

Upvotes: 6

stevelove
stevelove

Reputation: 3204

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.

Upvotes: 1

Quentin
Quentin

Reputation: 943547

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.

Upvotes: 0

George
George

Reputation: 806

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.

Upvotes: 8

Bhanu Prakash Pandey
Bhanu Prakash Pandey

Reputation: 3785

try this

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

Upvotes: 0

Related Questions