I want to dynamically add javascript to an existing script element something like:
var se = document.createElement(\'script\');
se.setAttribute(\'type\', \'t
Using innerHTML will break if the text contains anything that can be interpreted as HTML such as <. It would be better to append one (or more) text nodes:
var se = document.createElement('script');
se.setAttribute('type', 'text/javascript');
se.appendChild(document.createTextNode('alert(1)'));
document.getElementsByTagName('head').item(0).appendChild(se);