Aviation Web Development

URL Encoding

If you have to link to sites that take parameters in their URL make sure you understand how URLs should be encoded into anchor tags.

Example URLS

Using the Unit Conversion grid from the Griffin Helicopters site as an example.

The URL itself after clicking submit looks like
http://www.griffin-helicopters.co.uk/conversiongrid.asp?qty=100&fromunits=litre&fluid=JET+A1
While this is fine if you type it into the address bar, it is not valid if you encode an anchor tag like this. To encode this URL properly a couple of steps need completing
  • Extract the Page URL
    In this case
    http://www.griffin-helicopters.co.uk/conversiongrid.asp
  • Extract the parameters to the page, in this case
    ?qty=100&fromunits=litre&fluid=JET+A1
    and encode them by replacing the Ampersands (& to you and I) with the string & which will make this set of paramters into
    ?qty=100&fromunits=litre&fluid=JET+A1
  • Reassemble the URL, in our example the newly encoded URL would look like
    http://www.griffin-helicopters.co.uk/conversiongrid.asp?qty=100&fromunits=litre&fluid=JET+A1
    in the href attribute of an anchor tag that used these parameters, you can see the example working by following this liink to the Griffin Unit Conversion Grid with parameters.
ASP.Net
SQL Server
jQuery
W3C
Google
Bing