Created
November 19, 2013 12:35
-
-
Save davidbarredo/7544705 to your computer and use it in GitHub Desktop.
Dynamically add a script of a github gist
This file contains 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
/* Create script element */ | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = 'https://gist.github.com/7544705.js'; | |
/* Backup document.write function */ | |
if(!document._write) document._write = document.write; | |
/* Override document.write function */ | |
document.write = function (str) { | |
document.getElementById('scriptCont').innerHTML += str; | |
}; | |
/* Append the script element to #scriptCont */ | |
document.getElementById('scriptCont').appendChild(script); | |
/* When the script load, restore the document.write function */ | |
script.onload = function () { | |
setTimeout(function(){ | |
document.write = document._write; | |
},0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment