I am using Javascript to generate additional custom javascript and then adding it to the HEAD tag. The code below works great adding a javascript file, but what if the script is in a variable just generated?
var scriptTag = document.createElement(\"script\");
scriptTag.setAttribute(\"type\", \"text/javascript\");
scriptTag.setAttribute(\"src\", \"myfile.js\");
document.getElementsByTagName(\"head\")[0].appendChild(scriptTag);
Thank you for your attention.





Rating:
The post How do I add dynamic javascript to the head tag from a string, not a file? appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/how-do-i-add-dynamic-javascript-to-the-head-tag-from-a-string-not-a-file.html
No comments:
Post a Comment