Little tweaks with javascript : Bookmarklets.
A bookmarklet is a snippet of Javascript that can be bookmarked (or saved as a favorite) inside your web browser. Bookmarklets can enhance web pages, add special functionality using javascript which is supported by most browsers today and make your browsing experience a lot more efficient by offering one-click access. I will first start with basics.
Consider a simple javascript :
- javascript:alert('You clicked on the page');
- javascript:function ab(){alert("hello") ;};void(setInterval(ab,1));
Now filling form with javascript :
- javascript:function ab() {document.forms[0].login_username.value="someText" ; } ab() ;
And lets try to take some user-input :
- javascript:function ab() {q=document.getSelection(); if(!q) {void(q=prompt('Text :',''))} else alert(q)} ab();
- javascript:function ab(){q=document.getSelection(); if(!q){void(q=prompt('Search Text at My Blog: ',''))} location.href="http://www.technorati.com/search/ "+q+" linux?from=http://burad.blogspot.com "; }; ab();
An equivalent script for searching on wikipedia is :
- javascript:(function(){q=document.getSelection(); if(!q){void(q=prompt('Wikipedia keywords:',''))}; if(q) location.href= 'http://en.wikipedia.org/w/wiki.phtml?search='+escape(q)})()
Search Burad's Blog
Or for wikipedia
Search Wikipedia
Some more bookmarklets :
Scale Images
Sort Table
Transpose Table
Show Password
So in a way they are different from bookmarks and provides extra functionality through power of javascript. Here are some more javascript bookmarklet
You can view source for each bookmarklet by viewing page source .
You can find more bookmarklets at : http://www.squarefree.com/bookmarklets/
See this helpful screencast on bookmarklets.
Some More Example at Wisdombay
Updated : For changing documenet backgrounds :
Change to Red
Change to green
Change to blue
This may not work with pages using css
2 comments:
Thanks a lot for a very nice write-up on bookmarklets!
Dear Ajith,
I found your blog through Google BlogSearch and found it very interesting. May be your readers could benefit from the Bookmarklet section on my site, which we keep updated on a daily basis. You can access it here
http://www.wisdombay.com/bm/bm00001.htm
Post a Comment