/ Published in: JavaScript

This function allows you to open a new window, without using any inline Javascript. Simply add rel="external" to the link you wish to open in a new window.
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"; } } }
Comments
