Question

The <noscript> tag can be used to display a message if the user has scripting turned off - but is there any way in which it can be used to contain a conditional (html) statement, or more complicated coding?

Edit: Sorry, perhaps I wasn't clear; I have nothing against the noscript tag itself - but was wondering about the upward limitations of its usage? As far as I have seen, its usage has been merely to tell people to turn scripting on. I'm thinking about potential in terms of accessibility.

Was it helpful?

Solution

What's wrong with <noscript>? It can contain anything you'd want. From entire layouts, to <style> elements to a big fat warning message.

Obviously, you can't use JavaScript inside of it, but aside from that, you can do anything.

OTHER TIPS

You could do this:

<div id="removeIfJS">Sorry, but javascript is disabled</div>
<script>
 var sorry = document.getElementById("removeIfJS");
 sorry.parentNode.removeChild(sorry);
</script>

Stick to the noscript tag because it's the standard method to solve things. Search engines knows how to deal with it, screen readers know to deal with it and people that have turned javascript off will see a fancy warning/message (with some CSS).

BTW: You cannot do any fancy stuff if scripting is turned off as well.

In a noscript tag you can use all elements that are allowed directly in a body tag. See the link you provided for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top