More than meets the eye
Virtually everyone knows how to bookmark a webpage, unexciting and as commonplace as using a search engine: Firefox and Chrome users know how to "Bookmark this page", fans of Internet Explorer use "Add to favorites", and Safari surfers click "Add bookmark" from a menu.
A simple example -- page scrolling with bookmarks
- Create a new bookmark, pasting the prefixed and encoded snippet in the URL field.
To illustrate, I created the following line of JS to scroll to the top of a webpage:
After being URL encoded and prefixed, the snippet looks like this:
Finally, the snippet was copied and pasted into the URL field of a new bookmark I named "Scroll to top." For convenience, I placed the bookmark in IE's Favorites toolbar and added an icon:
Similarly, the image below shows a new Scroll to bottom shortcut created for placement in Chrome's Bookmarks bar.
Again, starting with a normal line of JS code:
What is my IP
Taking "bookmarklets" a step further, I decided to create a JS shortcut that would open a popup window and display my IP address. I found and used this free service -- with its easy to use JS code -- to provide IP data. Finally, I used encoded a JS bookmark snippet to open a popup window, then use the document.write method to push an entire HTML document to the newly opened popup. The final encoded string became this:
This is a screenshot of the bookmark applet running on IE:
NOTE: If your bookmark code utilizes a popup like the snippet above, your browser may prevent the code from executing due to security settings or if you use a popup blocker such as Firefox's Adblock extension.
That being said, without changing browser settings, I found the snippet above not only ran in the desktop version of Internet Explorer but also on the iPad version of Safari:
This article is published as part of the IDG Contributor Network. Want to Join?