Bookmarklets: quickly link to a website

[2011-01-07] browser, bookmarklet, hack, blogging, computers
(Ad, please don’t block)
Copying links to web pages is tedious, because you have to go to them twice in order to copy both URL and title. The following three bookmarklets help speed up that process by letting you copy everything in one go. Click on a link to try it out or move it to the bookmarks bar to use it later, on any page.
  1. For HTML WYSIWYG editors: wysiwyg link
    • Usage: Run bookmarklet, select all, paste into your HTML editor. Works great with Blogger.
    • JavaScript: document.body.innerHTML='<a href="'+document.location.href+'">'+document.title+'</a>';void(0)
  2. For HTML source code editors: source link
    • Usage: Run bookmarklet, copy the current selection, hit Return, paste somewhere.
    • JavaScript: prompt('HTML source:', '<a href="'+document.location.href+'">'+document.title+'</a>');void(0)
  3. For other editors: title + url
    • Usage: Run bookmarklet, copy the current selection, hit Return, paste somewhere.
    • JavaScript: prompt("Title and URL:", document.title+" "+document.location.href);void(0)
Update 2011-05-21: A new bookmarklet combines (1), (2), (3) and additionally takes the selection into consideration.