Forum Moderators: open
The next step was to be more Standards-Compliant and so I replace target="_blank" with rel="external" and then called some JavaScript for the external links. JavaScript code below:
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
This works in IE and Firefox. Any ideas how to get this working on Safari, or what is the correct way of opening links in new windows?
You need to break up the code and use alert() to find out where it's going wrong. However, if Safari supports it, try either turning on error reporting or opening a javscript console to (view error messages). I've never used Safari but it should support one of these.
It's also possible that the code is fine but you need to change a setting on Safari.
It might even be doctype-related, maybe.
Kaled.