//function to open external links in a new window function extLinks() { //alert('INIT'); // if the browser does not support DOM 1.0, return to the page and halt the script if (!document.getElementsByTagName) return; //get all the links on the page and place them into an array var arrAnchors = document.getElementsByTagName("a"); // for each element in the anchors array for (var i = 0; i < arrAnchors.length; i++) { //set a local temp var to hold the current link var aElem = arrAnchors[i]; //if the link contains our 'rel="external"' attribute if (aElem.getAttribute("href") && aElem.getAttribute("rel") == "external") //set its' target attribute to '_blank' aElem.target = "_blank"; } } //when the document has finished loading, call the function window.onload = extLinks;