When a someone tries to go to a page that is not on this site they will get a 404 error. A 404 error is the HTTP server code for file not found. The server then displays an error message which is just a HTML message that can be specified, this means it can be customized and made useful.
Click here for an example of a broken link to see the 404-error served up by JSResource.com.
The 404 Error page displays the link that is and the referring document on the page. There is also a link to an e-mail address on the page which will put this information into the subject line of the message.
Gathering the Info
loc = document.location.href;
ref = document.referrer;
<B>Broken Link:</B> “+loc+”
<B>Referring Document:</B> “+ref+”
This would display:
Mailing out the Information
The best way to do this would be to have a sever-side script automatically mail out the information above on each 404 error. I don’t want an e-mail for every broken link on my site, which may or may not be legitimately a broken link. So if I require a user to send out the link I will get fewer e-mails, and the e-mails should be more accuratly representing a broken link.
So I use a simple mailto: to send out the link, and have the subject line already specified in the e-mail message. This is done with by adding ?subject=SUBJECT LINE to the end of the mailto.
document.write<A HREF=’mailto:web@JSResource.com?subject=404 URL: ” + loc +” REFERRER: ” + ref +”‘>web@JSResource.com</A>”);