Blog Post RSS ?

Blogs » JavaScript & CSS » Bookmarklets
 

Bookmarklets

by Simon Willison

My latest SitePoint article is up: Better Living Through Bookmarklets. I’m a huge fan of bookmarklets and the article details some of my favourites and demonstrates some tricks for writing your own.

In the short time since I wrote the article I’ve come across a couple of new bookmarklets that deserve a mention. Mouseover DOM inspector allows you to inspect the structure of a page, showing a window with the element type and attributes for whatever is currently under your mouse pointer. Topographic page layout reveals the “depth” of elements on a page by changing their background colour - a useful alternative to tools that add borders to elements as borders can slightly alter a layout while background colour changes leave the shape of a page intact.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Ping.fm
  • TwitThis

This post has 6 responses so far

  1. I wonder who first ceated the bookmarklets…

     
  2. Yeah, million dollar question!! Bookmarklets have been around for quite a while but who implemented them first? Any answers Simon? :D

     
  3. I’m not Simon, but Steve Kangas over at bookmarklets.com says that the original idea came from Netscape.

    Simon, I noticed that your article doesn’t say anything about Safari. It can be worth pointing out that Safari has some oddities in how it handles bookmarklets (drat it!). I wrote an article about Safari bookmarklets in the March issue of Macworld magazine.

     
  4. I haven’t the slightest idea. http://www.bookmarklets.com is the first site I ever saw that popularised them, but I don’t know if the author of the site “discovered” them. The real question is whether or not they were initially a deliberate browser feature. Did Netscape (I’m guessing NS was the first browser to support them as they created Javascript in the first place) deliberately allow bookmarks to contain Javascript, or was it a bug that was later cleverly exploited? I’d be interested to know the answer.

     
  5. And here it is; I emailed Brendan Eich and asked him:

    They were a deliberate feature in this sense: I invented the javascript: URL along with JavaScript in 1995, and intended that javascript: URLs could be used as any other kind of URL, including being bookmark-able.

    In particular, I made it possible to generate a new document by loading, e.g. javascript:’hello, world’, but also (key for bookmarklets) to run arbitrary script against the DOM of the current document, e.g. javascript:alert(document.links[0].href). The difference is that the latter kind of URL use an expression that evaluates to the undefined type in JS. I added the void operator to JS before Netscape 2 shipped to make it easy to discard any non-undefined value in a javascript: URL.

     
  6. That’s odd - I could have sworn Dori’s answer wasn’t there when I posted my last two comments. I think it’s because her comment was posted anonymously and went in to the moderation queue - by the time it had been moderated and appeared in its place on the thread I had posted two more responses.

     

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow us on Twitter