Wednesday, May 3rd, 2006

Hyperlinks 2.0 – Ajax WTF

Category: Programming

Another Daily WTF featuring Ajax (mis)use. I know there’s a risk people will use Canvas graphics and other tricks to reinvent HTML widgets, but I never thought of this one: Using remoting, DHTML, and URL modification to build a brand new hyperlink system! Resume-Driven Development at its finest.

On the bright side, this would actually make a pretty nice programming exercise :-).

Instead of being coded in HTML pages, all hyperlinks are assigned a numeric identifier and kept in a database table. This identifier is then used on the HTML pages within an anchor tag:

<a href="Javascript: followLink(124);">View Products</a>

When the user clicks on the hyperlink, the followLink() Javascript function is executed and the following occur:

  • a translucent layer (DIV) is placed over the entire page, causing it to appear “grayed out”, and …
  • a “please wait” layer is placed on top of that, with an animated pendulum swinging back and forth, then …
  • the XmlHttpRequest object is used to call the “GetHyperlink” web service which, in turn …
  • opens a connection to the database server to …
  • log the request in the RequestedHyperlinks table and …
  • retrieves the URL from the Hyperlinks table, then …
  • returns it to the client script, which then …
  • sets the window.location property to the URL retrieved, which causes …
  • the user to be redirected to the appropriate page

Now that’s two-point-ohey.

Posted by Michael Mahemoff at 5:33 pm
13 Comments

+++--
3.6 rating from 39 votes

13 Comments »

Comments feed TrackBack URI

Oh boy! I’ll be scared to click on any link on that site! Sometimes an overkill is AN OVERKILL :-)

Comment by Somah — May 3, 2006

Sounds a lot like the link redirection that MacNN.com and some other sites have already been using for years to track what their reader are clicking on. This is just an Ajax way of doing it.

Comment by Twist — May 3, 2006

Ok, so i have seen much wors things on the DailyWTF, but this isn’t really as bad as the others, strange, but not as bad.

Comment by Ahmed — May 3, 2006

What made me laugh is that RDD stuff. If a developer starts to complain about something which helps finish projects on time and on budget because of their resumer, I would just simply fire them along the line “Now what do you think, how *this* will help your resume?” :)

Crazty times ahead, I tell you :P

Comment by András Tarsoly — May 3, 2006

[…] TheDailyWTF: Hyperlink 2.0 (via) […]

Pingback by TheDailyWTF: Hyperlink 2.0 at The Hero Dies in This One — May 4, 2006

Couldn’t he have just pulled the url out of the database and put it into the href in the page? Then secondary, have an onclick which returns true which calls the ajax fancy stuff, if javascript is avaliable.

Comment by Dave Ashe — May 4, 2006

LMAO.. nice post. saved my lunch. Sometimes i also have the feeling that things are just too easy ^.^ But hey.. the hard way can be fun aswell! :)

Comment by m3nt0r — May 4, 2006

Using JavaScript hyperlinks like that will play havok with Search Engine Optimisation. Google/Yahoo bots etc. simply can’t follow JavaScript hyperlinks, so your website will rank poorly in the search engines.

Comment by Sunday Ironfoot — May 4, 2006

I’ve worked in several large companies and never saw RDD, I saw alot of people (including myself) who would rather use something new like .net to gain experience and better myself. If your in a real company, you will get sent to training sessions etc to ramp up with that language and the customer WILL benefit from the faster dev time. Theres a big difference from learning a better language to get the job done faster / cleaner, than RDD. Even if they are learning that new language at the cost of the customer, they are bringing an asset to your company, so the next time they use it they will be better / faster. This sounds more like crappy managment at crappy companies whining that they cant retain engineers

Comment by Allen — May 4, 2006

Actually, my company using is JavaScript for our pay-per-click links in our syndicated articles to check to see if our article has money attached to it. If the article has money, the link is set live by the JavaScript. If the article is out of money, the JavaScript doesn’t place a hyperlink in the story. Since we are using a redirect from our server to our client, the fact that search engines can’t see the link is not a big deal.

Sincerely,
Chris

Comment by Chris Felton — May 4, 2006

well i think one thing we can agree on, its not as bad as the guy that took strings of pure php :-X

Comment by Allen — May 4, 2006

maybe a better way to do so without giving up the robots:

Comment by xilanko — May 5, 2006

Yes, I saw that the other day. Pretty scary and idiotic.

I hope that Ajax will not end up like 1990’s HTML, full of useless junk.

Comment by Sugar — May 5, 2006

Leave a comment

You must be logged in to post a comment.