Created
November 7, 2012 02:07
-
-
Save calderonsteven/4029163 to your computer and use it in GitHub Desktop.
inject css and js via javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function includeCSSfile(href) { | |
| var head_node = document.getElementsByTagName('head')[0]; | |
| var link_tag = document.createElement('link'); | |
| link_tag.setAttribute('rel', 'stylesheet'); | |
| link_tag.setAttribute('type', 'text/css'); | |
| link_tag.setAttribute('href', href); | |
| head_node.appendChild(link_tag); | |
| } | |
| function includeJavascript(src) { | |
| if (document.createElement && document.getElementsByTagName) { | |
| var head_tag = document.getElementsByTagName('head')[0]; | |
| var script_tag = document.createElement('script'); | |
| script_tag.setAttribute('type', 'text/javascript'); | |
| script_tag.setAttribute('src', src); | |
| head_tag.appendChild(script_tag); | |
| } | |
| } | |
| // Include javascript src file | |
| includeJavascript("http://www.mydomain.com/script/mynewscript.js"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment