Reputation: 1
i need to inject some content into DOM which is contained inside noscript tag
<noscript>
<!-- BEGIN app block -->
<script>
var ampry_acc_code = "ec494dd3-e6a4-4614-a93a-2ece1b713d16";
</script>
<!-- END app app block -->
</noscript>
I tried several methods like html().replace, textContent, those are not very helpful as producing strings
function Content(){
var content = document.querySelector('noscript').innerHTML;
document.body.innerHTML += content;
};Content()
Upvotes: -1
Views: 87
Reputation: 913
here's a simple way to do it, workable solution
document.querySelectorAll("noscript").forEach(function(a){a=a.textContent;a=document.createRange().createContextualFragment(a);document.body.appendChild(a)});
<noscript>
<!-- BEGIN app block -->
<script>
var ampry_acc_code = "ec494dd3-e6a4-4614-a93a-2ece1b713d16";console.log('working')
</script>
<!-- END app app block -->
</noscript>
Upvotes: 0