Simple Client Side Code

This page gives some examples of some useful client side JavaScript that anyone with their own web site may find useful. There are a number of third party applications that perform similar functions but they are often either expensive, require server side code or will slow down your site. All of the examples given below, can be easily be implemented by anybody with a text editor such as Notepad and some basic knowledge of HTML and JavaScript.

Location Dependent Hyperlinks

Sometimes you might want a link to go to different sites depending upon where they are being viewed. For example, you might want the user to be directed to amazon.co.uk if they are in the UK or amazon.com if they are in the USA (this would be particularly helpful if you are using affiliate links). There is some third party plug-ins that could be used with blogging tools such as Word Press but these will only work if you are paying for server side hosting. A far easier way is to use JavaScript functionality to get the time zone on the user's PC and then set different links accordingly.

The following simple example would be inserted into the head part of the HTML page and will set the hyperlink titled linkAmazon to go to amazon.co.uk if the PCs clock is set to the GMT time zone (for the UK) but will otherwise set it amazon.com:

In the body of the HTML use the following JavaScript after creating the hyperlink:

You can test this by double clicking on the clock on your PC and changing the time settings backwards and forward.

Search Site Box

Again, a number of companies are willing to charge you a lot of money to provide search functionality within your web site. It is possible, however, to use some simple HTML to 'piggy back' on Google's own search functionality by telling it just to search your own site.

In the example below, a search box is added to the web page which uses "http://www.google.com/search" to search a site with the value of "tomcoote.net" for the text supplied in the input text box:

You can test out this search box using the one in the top right of this page.

Email Form

If your web site hosting service includes support for server side code then they will probably provide you with an API for sending and receiving emails from your site. However, if the user has Outlook running you can use some simple HTML to 'piggy back' on its functionality.

In the example below - taken from the About page of this web site - the user is redirected to a 'thanks' page after clicking on the Submit button:

NB You should also display your email address for users who don't have Outlook running on their PC.

 

Full Length Books

Tearing up the Silk Road

Two Globes A 100,000 word travelogue detailing a journey from China to Istanbul, through Central Asia, Iran and the Caucasus.

Click here to view more details and the original book blurb for the back cover. You could also check out some of my initial ideas for book cover designs, view the final printed cover and check out the slide show.

amazon.co.uk | amazon.com

continue reading

Voodoo, Slaves and White Man's Graves

My second full-length travel book revolves around an overland journey through Benin, Togo, Ghana, Burkina Faso and Mali.

The book is now available in both print and eBook editions. Check out the West Africa Photo Gallery to view some pictures from this journey or view the full print version of the book cover.

amazon.co.uk | amazon.com

continue reading

Free eBooks

Turkmenbashi's Land of Fairy Tales

A Short Break in Libya

To Camels from Cows: Algeria Overland

All of these short eBooks are available for free in a variety of formats for use on such eReaders as Kindle, Nook and Sony Touch. After downloading the books in Kindle, Epub, RTF, PDB or PDF format, they can then be copied over to the eReader of your choice.

continue reading

Contact Me

If you would like to get in touch, then you can me email me at tom@tomcoote.net