I believe you want to set the src property on the script object, not the inner html. Something like this:
Code:
var script = document.createElement('script');
script.src = ''; //put whatever javascript you like here
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);