Tuesday, January 24th, 2006
Automatic external link interstitials using JavaScript and Behavior.js
Do you work in an industry that needs to be paranoid about privacy?
Patrick Fitzgerald works at WebMD, and had to make sure that users were warned when going to external areas.
You could go through every a href, but that is error prone, and isn’t safe.
In the Aspect world this would be a called a cross-cutting concern. You want to be able to declare in one place “all external links need to first filter through X”.
Patrick did just this using good old Behaviour.js as the implementation.












An interesting idea, but it failed for me as I have pop-ups blocked - therefore, I am not notified of the different policy, etc. If WebMD is doing this to try to shield themselves from potential liability, I would argue this isn’t very effective given the popularity of pop-up blockers.
I’d suggest an inline DIV as a pop-up substitute which holds the disclaimer/warning content, along with a regular link (or button) sans event handlers to the external site - similar perhaps to the inline image viewing script covered on here recently.
And if javascript is disabled?
[...] Inspired by Automatic external link interstitials using JavaScript and Behavior.js (via Ajaxian), I decided to try to implement the same idea using Yahoo! User Interface Library. (No, I don’t have new ideas, just sample code… read on!) Here’s the meat of the code: [...]