I employed something like this on my blog last night. A nagging but very visible problem that I have been having is differentiating between external and internal links in my posts. I always want my external links to open in a new window for the user, but I needed a way of telling them that the link would open a new window. Now, the fool's way would be to hard-code some kind of identifier inside the link tag to let the person know, but I decided a better way. Why not let a script run through my links, and alter them if they are marked as external links?
So I made up a simple but useful script! It checks the
rel attribute of all links, and whenever it finds a match for
ext, it'll append an image to it, and make its
target="_blank". Simple, unobtrusive, and saves tons of hardcoding time. Although a problem arises if you want certain links not to be affected, yet keep them external. But for that, you can always use a third value for
This is only one of the basic uses of scripts to do repititive tasks. Scripts are powerful things, and should be used whenever their need be sensed. Ofcourse, don't go overboard otherwise your page will have ten's of scripts running at page load and hence will slow down the loading times. That is not good! :) So find innovative ways of using this, you won't regret it!
[Info]: The auto external links script is something like Kirk's over at Phydeaux3. I'll admit the idea stemmed from there! :)