Is the following HTML/Javascript valid (strict) when Javascript is enabled? Is the id in the noscipt tag ignored?
<body>
<noscript>
<div id="test"></div>
</noscript>
<script type="text/Javascript">
var el = document.createElement('span');
el.id = 'test';
document.body.appendChild(el);
</script>
</body>
When javascript is enabled, the content of <noscript>
is raw text, not element content, so the child of the <noscript>
element is a text node with value "\n <div id="test"></div>\n"
instead of a DIV element. A getElementById("test")
will not find a <div>
with the ID "test"
because there is no such element, only a text node whose content would parse to a DIV if it appeared outside a raw text context.
http://www.w3.org/TR/html5/scripting-1.html#the-noscript-element
Outside of head elements, if scripting is enabled for the
noscript
element
Thenoscript
element must contain only text...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With