Client-side TrackBack
Have an article that references someone else's article? Does that reference have a TrackBack URI? Does your publishing system (Blogger, Notepad, etc.) not have TrackBack built in? Want to be polite and make more work for yourself? Then I have the solution right here!
Six Apart's TrackBack protocol is implemented as a simple HTTP POST request. Excerpts are trimmed to a maximum of 255 characters. At the bottom of this page is a form that implements this protocol with the aid of some JavaScript.
This tentative foray into the mysterious world of JavaScript has questionable relevance, but it works, and elicits hand-rubbing glee whenever I see the reference page updates with the TrackBack message. I can be very simple at times. Okay, most of the time.
Obviously some amount of mischief can be caused, but like all technology, it can be used for good, or for awesome. I've put a limiter such that you'd have to refresh the page in order to send another TrackBack ping. It wouldn't be nice if more than one ping wound up on the referenced page.
I note that I don't know how this thing responds to non-ASCII characters. The spec is inflexible when it comes to those details, insisting on human readable
text for the title, excerpt, and blog_name fields.
If you are so inclined, skip past the TrackBack form for some observations on the implementation process.
The Produkkt!
Lessons
The first incarnation was hacked together a long time ago using one visible form for input, and one hidden form for submission, with some JavaScript to do some processing like trimming the excerpt length should it exceed 255 characters. Since then, I've tried to incorporate some AJAX using XMLHttpRequest but because of cross-site scripting security concerns, neither browser I tried — Firefox and IE — would permit a connection to be opened. The small snippet of AJAX-relevant code is commented out in the page source, as a point of curiosity for any interested persons.
The form(s) have been updated to be XHTML 1.1 compliant. Rather than having JavaScript write out the hidden form outside of the document body, I've put it in the body but hid it using CSS. Also, parameters are pulled by JavaScript using the DOM's getElementById function, as opposed to hard-coding. This was done to be XHTML compliant more than anything else.
When pulling and setting fields using the DOM, getElementBytId requires you to give each field, well, an id attribute. However, when it comes time to submit the form, the browser relies on name attributes to collect the field data. If the name attribute isn't included, nothing will be posted. This proved to be the biggest time-waster in making the transition to compliant XHTML.
In this example, all of the id and name attributes are unique to each field, because getElementById is global in its operation. I didn't put any name attributes into the visible form fields, as I'm not setting any of them, merely pulling data. Also, I'm lazy.
A cleaner solution would have been to use the document.forms collection, which would eliminate the need to use unique attribute strings across the two forms. It's something I might consider doing at a later point.