Postcode Lookup with Greasemonkey
 

Postcode Lookup with Greasemonkey

Our Postcode Lookup web service can be easily integrated with any website using Ajax or our simple Javascript popup solutions, but if you have to use a website regularly to enter address details that you don't have any control over, you may find yourself needing to add postcode lookup functionality to a website without being able to change the website itself.

This is quite easily acheivable using the Firefox web browser combined with the Greasemonkey addon. This allows additional, user-defined code to be run as part of specific web pages to enhace their functionality.

We have included a script for Greasemonkey to add a "Find Address" button on any web page you want to use it with. The instructions below will help you get started.

  1. Register

    If you haven't already registered for our Find My Nearest service, you'll need to do so now. Just fill in our quick registration form to get started. One of our account managers will contact you to ensure you get set up with the package that is best for you.

  2. Purchase

    Once you've registered, you will need to purchase a licence for the Postcode Lookup service. This allows you to use the Postcode Lookup service directly using web services or Ajax as well as using the ready-made Greasemonkey script.

    The purchasing wizard will take you through a few questions to ensure you get the best deal. Note that the Greasemonkey script is written with the assumption that you will buy single user licences. The website licences are not appropriate for use with the Greasemonkey script as the postcode lookup application is specific to your computer, not for any user of the website.

  3. Install Firefox 3.5

    If you haven't already installed Firefox 3.5, do so now. It's a free download and should only take a few minutes. Note that this script requires at least version 3.5 - it is not compatible with earlier versions.

    Download Firefox 3.5

  4. Install Greasemonkey

    If you haven't already installed Greasemonkey, do so now. It's a free addon for Firefox that makes this script work.

    Download Greasemonkey

  5. Install the PostcodeLookup script for Greasemonkey

    The script will be added to the set of available scripts in Greasemonkey. We'll now need to do a small amount of configuration to get it to work as necessary for the page you want to work with.

  6. Configure the script in Greasemonkey

    In Firefox, open the Greasemonkey manager by right-clicking on the monkey in the bottom right and selecting "Manage User Scripts". Select the PostcodeLookup script in the list on the left, and click "Add..." in the "Included Pages" section. Enter the address of the page you want to use the Postcode Lookup script with, and click OK.

    With the PostcodeLookup script still selected, click the "Edit" button in the bottom left corner. The first time you use this, you will be prompted to select a program to use to edit the script with. If you don't have a preferred editor, you can use Notepad (C:\Windows\Notepad.exe).

    When the script is opened in the selected editor, you will see the following lines near the top:

                            var pageConfigs = new Array();
                            var ajaxKey = 'YOUR-AJAX-KEY';
                        

    The first thing you will need to change is to replace the 'YOUR-AJAX-KEY' option with your own Ajax key. You can generate this at the Ajax key admin page - when generating the key, enter the domain name of the page you want to use this script with.

    Secondly, you will need to add an entry to the pageConfigs list to indicate where the various parts of the address should be stored in the page. To do this, add some new code following the template below:

                            pageConfigs['http://www.example.com/'] = {
                                buttonPos: 'zipcode',
                                add1: 'address1',
                                add2: 'address2',
                                add3: 'address3',
                                add4: 'address4',
                                town: 'city',
                                county: 'state',
                                postcode: 'zipcode'
                            };
                        
    • Replace the URL http://www.example.com/ with the address of the page you want to use the script with.
    • Change the buttonPos setting to the ID of the element in the page to display the "Find Address" button after.
    • Change the add1 to add6 settings to the IDs of the elements in the page to hold the address lines after an address has been selected.
    • If the town is required to be held in a specific field, use the town setting instead of add5.
    • If the county is required to be held in a specific field, use the county setting instead of add6.
    • Change the postcode setting to the ID of the element in the page to hold the postcode.

You are now ready to start using the Postcode Lookup functionality on your chosen web page. Simply refresh the page in Firefox to display the new "Find Address" button.

If you want to use this script with other web pages, simply add them into the Greasemonkey configuration and add the appropriate settings into the script for each page. You will also need to revisit the Ajax key generation page for each new domain, although the key it generates will be the same for each so you will not need to update this in the script.

Skip Navigation Links
Request handled by server S2 for client 38.107.179.218 at 08/02/2012 02:58:32