Skip to content

Instantly share code, notes, and snippets.

@lilliealbert
Created July 19, 2013 17:27
Show Gist options
  • Save lilliealbert/6040889 to your computer and use it in GitHub Desktop.
Save lilliealbert/6040889 to your computer and use it in GitHub Desktop.
javascript bookmarklet hell
javascript:(function() {
var jsCode = document.createElement('script');
jsCode.onLoad = function(){console.log('onLoad anon funtion called')};
jsCode.setAttribute('src', 'http://localhost:3000/test.js');
document.body.appendChild(jsCode);
})();
// if the console.log is inside of an anonymous function, it never gets called
// the onLoad call also doesn't seem to be able to see anything defined in the test.js file :(
function testFunction(){
console.log("made it into the test function");
}
testFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment