Insert any Javascript bookmarklet December 10th, 2007
As the natural extension of Gareth Rushgrove’s bookmarklets for inserting the Dojo or YUI Javascript toolkits mentioned by Simon, here’s a tidying-up of a bookmarklet I’ve been using to bring in any Javascript using user input via a popup prompt:
javascript:void(function(){
var%20s=document.createElement("script");
s.src=prompt("Full%20URL:");
document.getElementsByTagName("head")[0].appendChild(s);
}())
I was originally appending it to the body as an invisible div, making use of d.innerHTML to add both src and type attributes so as to make sure the browser won’t ignore it. The above based on Gareth’s seems to work fine, though.
December 10th, 2007 at 11:30 am
JP - you need to escape the “s in your bookmarklet, otherwise it gets truncated.
December 10th, 2007 at 11:39 am
You’re quite right, David: that’s what comes of posting at 4am. Fixed now.
December 20th, 2007 at 9:08 pm
[...] Let’s instead assume you’re following my every word. For this next bit, you’ll need Firefox and Firebug, or to stuff all these instructions into a single file. Otherwise, you’ll have to take my word for it. Firstly, I’ve included jQuery on every page of my blog, so if you’ve got the ‘bug then you don’t have to resort to my insert-JS bookmarklet to squirt it in. [...]