Creating a Bookmarklet


A bookmarklet is nothing but a simple Link. All that differs in the link is the href attribute value.

Lets make a simple whois bookmarklet (bkmlt), On clicking that bookmarklet, a prompt will ask for the domain, and on submitting the information… takes you to the whois page

The href attribute in bkmlt is all javascript

var dm = prompt(“Enter IP / Domain”, “google.com”);
if (dm.length > 0) {
window.location = “Enter IP / Domain”, “google.com” + dm;
}

The above javascript is very simple, prompts for a domain/IP, and changes the window’s location to the url…

Now to convert the code to bkmlt, all you need to do is delete the retunrn characters, making the code look like

javascript:var dm = prompt(“Enter IP / Domain”, “google.com”); if (dm.length > 0){ window.location = “Enter IP / Domain”, “google.com” + dm; }

Note the addition of the string “javascript:” before the code

The code is ready to be inserted into the bkmlt

  1. Right click the bookmarks toolbar in Firefox
  2. New Bookmark…
  3. In the Location attribute of bookmark, add the above code.
  4. Name the bookmarklet to your need
  5. …and the bkmlt is ready.

One Response to “Creating a Bookmarklet”

  1. GET / HTTP/1.1 » Blog Archive » Wikipedia Bookmarklet Says:

    […] If you are unfamiliar how to create a bookmarklet, take a look here. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: