Skip to content
Create a gist now

Instantly share code, notes, and snippets.

function noteval(code, doc){
// add some javascript to a document, like an iframe
// var iframe = document.getElementById("theframe");
// noteval('alert("hi")', iframe.contentDocument || iframe.)
var e = doc.createElement("script"),
how = "text" in e ? "text" :
"textContent" in e ? "textContent" :
"innerHTML" in e ? "innerHTML" :
if(how == "appendChild"){
e[how] = code;
(doc.head || doc.getElementsByTagName("head")[0]).appendChild(e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.