Internet bookmarklets

(New page: Although not widely known, in most browsers you can run javascripts by typing them in the url-bar. This script can then do anything a regular script loaded from a website can. If you bookm...)
Line 11: Line 11:
[[Category:Users]]
[[Category:Users]]
 +
[[Category:Web]]

Revision as of 13:25, 29 October 2009

Although not widely known, in most browsers you can run javascripts by typing them in the url-bar. This script can then do anything a regular script loaded from a website can. If you bookmark such a script then it is called a bookmarklet.

Here are some examples. Just bookmark the links on that page and you're ready to use them.

These scripts should start with 'javascript:', can only contain one line and function calls should be enclosed with the 'void()' statement, unless they're called from within another function. This bookmarklet for example changes the font and background color of a page:

javascript:void(main());function main(){c('body');c('td');c('div');c('p');}
function c(elname){el=document.getElementsByTagName(elname);
for(i=0;i<el.length;i++){el[i].style.background='black';el[i].style.color='white';}}

Note: The code has been divided into three lines to fit on the wiki page.