var script = document.createElement('script'); script.appendChild(document.createTextNode('alert("Ya");')); document.head.appendChild(script);