function init() {
var links = document.getElementsByTagName('a'); // grabs all the anchor tags

for(var i = 0; i < links.length; i++) { // loops through the anchor tags
var a = links[i]; // grab each anchor

if(a.href.indexOf('.pdf') != -1) { //replace the if statement to select the anchor tags you want; for example, replace 'xyz' with 'http://' to select only those links with "http://" in them for changing
a.onclick = function(){window.open(this.getAttribute('href'));return false;}; //this is where we do our actual work, as described in original hint
}
}
}
onload = init; // make sure we do all our magic as soon as the page loads