Sunday, April 03, 2005

Keyword Bookmarklets and Command Line Arguments

I previously blogged about triggering Firefox bookmarklets form a keyword entered in the browser address line. What I didn'r record was how a command line argument could also be passed to a bookmarklet. This page on Keyword Bookmarklets for Scripters describes how the %s variable can be used to achieve this, so for example I can type directionsFromHomeTo MK76AA (not the shortest of keywords, admittedly!) and trigger a bookmark with my home postcode embedded in it that calls up a route finder from my home to MK76AA.

An example bookmarklet is here, essential bits of the code is as follows (you wouldhave to use whatever variable names the actual routefinder service requires, of course):
javascript:

homePostCode='EH37QJ'; //for example...
location.href= '...' //Routefinder URL here
+'&fromPostCode='+homePostCode
+'&toPostCode=%s';


Del.icio.us tags:

0 Comments:

Post a Comment

<< Home