How to make an ‘email this’ link in a webpage

The trick here is to do a mailto: link and pass URL-encoded parameters called “subject” and “body”. I found that the ridiculous Windows email client on this machine (which I never use except for testing this) doesn’t understand spaces encoded as “+”, it needs “%20″.

<a href=”mailto:?subject=This%20is%20the%20subject&amp;body=http://yoururlgoeshere/”>Email this</a>
The ampersand “&” between the parameters is HTML encoded which is a bit fussy but correct.
Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

URL encoding

Here’s an example of URL encoding from the article Forms and buttons: Sending data to the server:

formtest2.html?message1=Things+%26+stuff&ucannotseeme=boo!&message2=Hello+World

Why URL encoding? Well, firstly, data items in the request is separated by and ampersand “&”. In the above example, the hidden data contains an ampersand. If this wasn’t encoded somehow then how can anyone know where the data item ends? So “&” becomes “%26″ (it’s ASCII value [numeric code representing the character] written in hexadecimal [a number system common on computers which uses 16 digits instead of the 10 digits used in binary])

(more…)

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

Forms and buttons: Sending data to the server

Using google is an everyday event for a large percentage of the human population. Ever wonder what is going on when you hit the button? Here’s a working example which searches this site (right click and save then double click it to try it out). Ignore the complicated header, it’s just so the example validates.

We surround the information to be sent in a FORM tag:

<form action="http://www.jameswilkesdesign.co.uk/" method="get">

(more…)

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How to put a ‘back to top’ link at the bottom of a page

Long webpages often have a link to take the user back to the top of the page. 2 things are needed for this. Immediately inside the body tag of your HTML document put:

<a name=”top”></a>

This is an anchor, with a specified name. To link to it you use a link the name, prefixed with # to show that the link is to the same page (this tells the browser it doesn’t need to reload the page)

<a href=”#top”>Back to top</a>

You can also use this to make a table of contents by putting anchors at the start of each section of the page.

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How to make an email link using “mailto:”

Often you see links which open up your email program with the address already filled in for you. Here’s how you do it:

<a href=”mailto:bob@example.com”>bob@example.com</a>

(more…)

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter