Monday, April 04, 2005

Prompt or User Selection Bookmarklets: Postcodes & UK dialing Codes

I have been doodling for some time with a series of bookmarklets that make use of UK Postcodes to launch map or routefinder webpages.

But one thing keeps bugging me: how to write a bookmark, triggered by a Firefox Keyword, that will accept input from either the address line or from a user postcode selection on the web page currently being viewed.

This bookmarklet is not quite the solution I had in mind (it doesn't accept an argument from the address line) but it will offer a prompt for user input if text on the page isn't highlighted. However, it does have the advantage that it always works as a button on the bookmarklet toolbar. Here's the code:

if(!tel) void(tel=prompt('Dialling Code: '));

In case you were wondering here's a postcode bookmarklet that takes a postcode as a user selection, or failing that, from a prompt, and finds the route to it from an embedded postcode using the Michelin routefinder.

if (!pc) void(pc=prompt('Destination postcode: '));
homePostCode='MK7 6AA';
location.href='...//path to routefinder
+'?reinit=1&strStartCP='+homePostCode+'&strDestCP='+pc tags:


Post a Comment

<< Home