Introduction
This handy piece off code will rewrite all the (a href) links to target a new window this is very handy in the case of rss feeds nested within iframes in your applications where the code returned by the feed does not always target a new window
Background
A while back i had to insert a news feed into my ajax enabled website and due to the nature of my ajax engine i had to create a iframe (containing my feed) inside a div everytime the ajax event ended, problem was that the links returned from FT.com had one link that caused the page in the iframe to load their home page in the frame when clicked, there was no way to alter the links using target because these links get returned from another server so i came across a handy little script i had to change a bit to do exactly what needed to be done
Using the code
put this code in script tags just underneath the body tag of the page you want to nest in the iframe
onload = function(){
var getElementsByTagName('a');
for(var i = 0; i < links.length; ++i){
links[i].setAttribute('target','_blank');
}
}