Ask YC: How do you build a bookmarklet?

9 points by qwestion ↗ HN
I a non-programming founder trying to contribute towards the development of our web app and tonight I was trying to create a javascript bookmarklet to easily submit content to our Social News from my Firefox toolbar. My search skills are not too bad, but I couldn't find something that worked for me. I still have a lot of questions unanswered. Hence I decided to ask you, the all knowing YC crowd.

Any help?

4 comments

[ 4.0 ms ] story [ 16.9 ms ] thread
Have you seen this wikipedia page? It has some good references:

http://en.wikipedia.org/wiki/Bookmarklet

The basic idea is that you create a link on your page that points to a "javascript:" URL. This link can become a bookmark just like any other link. The javascript in the link's URL implements your bookmarklet functionality.

Looking at del.icio.us's bookmarklet may be a good start:

  javascript:location.href='http://del.icio.us/post?v=4;url='+encodeURIComponent(location.href)+';title='+encodeURIComponent(document.title.replace(/%5E%5Cs*%7C%5Cs*$/g,''))
Basically, it redirects the browser to http://del.icio.us/post?v=4 and passes two parameters to the URL: "url" and "title" which just contains the url and the website title of the previous website you were on.