I'm trying to get the content of a <noscript>
tag using Javascript. I succesfully managed to get it in FF, Chrome, Opera and even IE6 but fail on IE7 (haven't tried IE8+ yet).
Basically, here's the reduced code version :
<noscript>Lorem ipsum</noscript>
<script>
var noscript = document.getElementsByTagName('noscript')[0];
noscript.textContent; // undefined
noscript.innerHTML; // empty string
noscript.childNodes.length; // 0
</script>
I tried adding element inside and targeting them, no success. I tried to wrap in a parent element and getting its .innerHTML
, but anything between <noscript>
tags is discarded.
Note : I'm building a lazyloader script and the <noscript>
element is just what I need (<img>
src
attributes inside a <noscript>
tag are not fetched by the browser.)
document.getElementsByTagName('script')[0]
- you're querying for a script element, not a noscript element. What did I miss? – Bivinsnoscript
content to display as normal DOM elements for js-disabled browsers but also want to be able to replace thenoscript
todiv
(for example) to display it on demand – Wetterhorn