function createScript(script) { var myScript = document.createElement("script"); myScript.type = "text/javascript"; myScript.appendChild(document.createTextNode(script)); document.body.appendChild(myScript); }