Dictionary.com Updated Bookmarklet

I use this really basic Firefox bookmarklet pretty much every day, so I thought I'd post it.

Dictionary.com provide an 'official' bookmarklet, here:
http://dictionary.reference.com/tools/bookmarklets.html

I've improved it a bit

* Selected text uses window.getSelection(), not document.getSelection()
* Trims junk out of current selection
* Opens a new window so you don't lose the current page
* Uses encodeURIComponent(), not escape()

Source (web.2point1.com)


Download Bookmarklet:


View Bookmarklet Code:

Bookmarklet Source Code:

javascript%3Avoid%2520%28function%28%29%7Btry%7Bvar%2520b%3Dwindow.getSelection%28%29%2Ca%3Db%3Fb.toString%28%29.replace%28/%28%5E%5CW+%7C%5CW+%24%29/g%2C%27%27%29%3A%27%27%3Bif%28%21a%29%7Ba%3Dprompt%28%27Enter%2520a%2520word%2520to%2520look%2520up%27%29%3Bif%28%21a%29return%7Dvar%2520c%3D%27http%3A//dictionary.reference.com/search%3Fr%3D1%26q%3D%27+encodeURIComponent%28a%29%3Bwindow.open%28c%29%7Dcatch%28d%29%7Balert%28%27Oops%3A%5Cn%27+d.message%29%7D%7D%29%28%29%3B


Rate it:


Tags:

Comments

Comments so far. Add yours.

John

This would be better if the marklet opened on a new tab. Right now, Ctrl+clicking the marklet forces you to type in the word again.