2

Why does this work when run in Chrome's Developer Tools (Console Tab):

var script = document.createElement( 'script' );
script.type = 'text/javascript'; 
script.src ='somescript.js'; 
$0.appendChild(script);

but this not work when added as a string using the Edit As HTML feature in Chrome's Developer Tools (Elements tab, editing body tag):

<script type="text/javascript" src="somescript.js"></script>

?

Contents of somescript.js:

console.log('some js is being run');

Defintion of "work" in this case:

some js is being run is printed as console output

Trindaz
  • 17,029
  • 21
  • 82
  • 111
  • @Oriol Why don't you point to the duplicate question since you're certain it exists? – matmo Aug 19 '16 at 00:33
  • Woops, I didn't see the "This question already has an answer here: ..." part with the referenced duplicate until I scrolled up, my apologies. – matmo Aug 19 '16 at 00:37
  • In short, Chrome's "edit as HTML" uses `innerHTML`, and that does parse ` – Oriol Aug 19 '16 at 00:41

0 Answers0