1

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.

4

3 に答える 3

4

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.

于 2012-10-14T21:22:38.197 に答える
2

You could do this:

<div id="removeIfJS">Sorry, but javascript is disabled</div>
<script>
 var sorry = document.getElementById("removeIfJS");
 sorry.parentNode.removeChild(sorry);
</script>
于 2012-10-14T21:20:04.813 に答える
2

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.

于 2012-10-14T21:27:13.453 に答える