[Computer programs] [Computer Programs] [Main Page] [More Javascripts]

Some Bookmarklets

Intro

Bookmarklets are small scripts that one stores in the browser bookmarks (or Favorites or QuickList or whatever. I'll call them bookmarks.). When one follows such a bookmark, the script is executed. Typically the scripts use the content of the current web-page somehow to do something useful. See the bookmarklets below for examples. For me bookmarklets are the only reason to have Javascript enabled.

To try the bookmarklets on this page, just click them. (On this page, links to bookmarklets look like this: don't click here. In favorable circumstances they should be distinguishable from ordinary links.)

If you want to store a bookmarklet, drag a link to the personal toolbar (or bookmarks menu or ...), or right-click a link and select "Add Bookmark" or something similar. Well, you should know how to use your browser.

Copyright Notice: All the bookmarklets here are freeware. You can use them and modify them freely to suit your purposes. You can sell them if you find someone stupid enough to buy. (Note, however, that I still have the copyright of this web page.)

For more information, or if you couldn't understand a word of the previous, see www.bookmarklets.com.

Contents

The table below lists all the bookmarklets available from here. The "Details" links lead to a longer descriptions, including e.g. readable source codes.

"NS version" "IE version" Description
Google! Google! Search the selected text with Google. Details
Links! Generate a list of links from a web page. Details
Validate! Validate the current page. Details
Check CSS! Check the stylesheet of the current page. Details
En-Fin! En-Fin! Look for the selected text in English-Finnish-English dictionary. Details

Google

[top] [next]

Description: Searches the selected text with Google, the best search engine. If no text is selected, the bookmarklet functions as a normal link to Google.

NS: Google! | IE: Google!
Tested and works: NS 4.7, IE 5.5 WinNT Works with Frames: Yes
Javascript version: 1.2 Length: 210 characters Modified: 2000-11-20
Original idea/source: www.bookmarklets.com.
Source code. Indents, comments, spaces and line-feeds added. This is for the NS version. IE version has "document.selection.createRange().text" in place of "document.getSelection()"
function x31H(Q) 
   // In: Q = selected text in current document
   // Out: the new URI
   var R,i,l
   l = top.length // Number of frames. If 0, the for-loop below has no effect

   // Look for selected text in all frames, if there are any.
   // At most 1 frame will contain a selection (I think)
   for ( i = 0; i < l; ++i )
      Q += frames[i].document.getSelection()

   R = 'http://www.google.com/'  // target URI
   return Q ? R + 'search?q=' + escape(Q) : R // Add query if any text was selected
};
location.href = x31H( document.getSelection() ) // direct browser to new address

List of links

[top] [previous] [next]

Description: Generates a list of links from the current page, and displays the list in another window. The links will open in the first window.

Links!
Tested and works: NS 4.7, IE 5.5 WinNT Works with Frames: Kinda [1]
Javascript version: 1.2 Lenght: 449 characters Modified: 2000-11-19
Original idea: own.
Source code. Indents, comments, spaces and line-feeds added.
function nh83fny(t)  
   var l,w,d,i,r
   if (!t.name) t.name = 'rvaJo'
   l = t.document.links       // List of all links on current page
   w = window.open('','LinkWin')

   with (w.document)
   

      // Write the head and heading
      writeln( '<title>Links of ' + t.document.location + 
               '<\/title><h1>Links<\/h1><ol>' )

      // Write the list of links
      for ( i = 0; i < l.length; i++ )
      
         // The following is needed only when the URL contains characters 
         // &, < or > (like on this page). Otherwise r = l[i].href would suffice
         r = l[i].href.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')
         writeln( '<li>' + r.link(r) )
         links[i].target=t.name // target to calling window
      }

      // Write the rest, bring the window on top
      write( '<\/ol>' )
      close()
   }
   w.focus()
};
nh83fny( top.length ? top.frames[top.length-1] : top ) // Call the function defined above

[1] The links in the last frame are listed.

Validate

[top] [previous] [next]

Description: Validates the current page using the W3C validator. On framed pages the document containing the frameset will be validated.

Validate!
Tested and works: NS 4.7, IE 5.5 WinNT Works with Frames: Sort of.
Javascript version: 1.0 Lenght: 85 characters Modified: 2000-05-10
Original idea/source: Newsgroup sfnet.viestinta.www.
Source code. Spaces added.
location.href = 'http://validator.w3.org/check?url=' + escape( window.location )

Check CSS

[top] [previous] [next]

Description: Checks the stylesheets of the current page using the W3C CSS-"validator". On framed pages the CSS of the frameset document is checked.

Check CSS!
Tested and works: NS 4.7 IE 5.5 WinNT Works with Frames: In a way.
Javascript version: 1.0 Lenght: 100 characters Modified: 2000-05-10
Original idea/source: Own.
Source code. Spaces added.
location.href = 'http://jigsaw.w3.org/css-validator/validator?uri=' + escape(window.location) 

English-Finnish-English

[top] [previous]

Description: Looks for the selected word in an English-Finnish-English online-dictionary. The result is shown in another window.

NS: EnFin! | IE: EnFin!
Tested and works: NS 4.7 WinNT Works with Frames: Yes.
Javascript version: 1.2 Lenght: 329 characters Modified: 2000-11-20
Original idea/source: Own.
Source code. Indents, comments, spaces and line-feeds added. This is for the NS version. IE version has "document.selection.createRange().text" in place of "document.getSelection()
function kDR67u(Q)
   // In: current selection; empty for framed pages
   var i,l,w;
   l = top.length; // Number of frames

   for ( i = 0; i < l; ++i )
      // At most one frame has a non-empty selection
      Q += frames[i].document.getSelection(); 

   // If nothing was selected, ask for a word
   if (!Q)
      Q = prompt( 'Translate Word...?', '' );
   
   // Open a dictionary window and scroll to proper position.
   // Edit width and height to fit your favorite browsing resolution.
   w = window.open('http://www.tracetech.net:8081?mm=1&word='+escape(Q),
                 'MoWiN','scrollbars,resizable,width=400,height=500');
   w.scrollTo(180,100);
};
kDR67u( document.getSelection() )


Program Index | Main Page | Next
Mikko Pekkarinen, Page created 2000-11-20, modified 2000-11-30. URL: https://iki.fi/empii/program/bookmarklets.html