/ Published in: JavaScript
opens links in new window, the standards compliant way, using rel="external" - for example: title="Download Adobe Reader" rel="external"
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function doStandardsCompliantExternalLinks() { if (!document.getElementsByTagName) {return;} var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") {// for example: title="Download Adobe Reader" rel="external" anchors[i].target = "_blank"; anchors[i].title += " - Opens in new window"; } } };