What is a bookmarklet?

A bookmarklet is similar to an extension, but is used by clicking a bookmark. According to wikipedia:

A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser. Bookmarklets are unobtrusive JavaScripts stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. Bookmarklets are usually JavaScript programs. Regardless of whether bookmarklet utilities are stored as bookmarks or hyperlinks, they add one-click functions to a browser or web page. When clicked, a bookmarklet performs one of a wide variety of operations, such as running a search query or extracting data from a table. For example, clicking on a bookmarklet after selecting text on a webpage could run an Internet search on the selected text and display a search engine results page.

Create a bookmarklet

Creating a bookmarklet is easy. (If you do know how to create a bookmark. If not read Creating A Bookmark )

Let's create a simple example:

First, create a bookmark. As for the title of the bookmark, name it “Hello World”. Instead of keeping the url of the page as the bookmark type javascript:alert(‘Hello World!’). There! Click save or whatever it is in your search engine. And click the bookmark. You should have an alert message saying “Hello World!” appear!

To run js in a bookmark, you need to have the javascript: prefix before it. You can only type one line so make sure to use your semicolons! In addition, you can not use double quotes. The search engine saves the bookmark in code that looks something like this: