Forum Moderators: open
How could I very simply make a page open in a new window if the domain name in the href attribute is different from a certain value?
I would like this to be applied to all the links in the current page.
Big thanks in advance.
<base target="_blank">
<a href="http://www.cognitivedistortion.com">Cognitive Distortion (New Window)</a><br>
<a href="http://www.digitalblasphemy.com">DigitalBlasphemy (New Window)</a><br>
<a href="http://www.ianadesign.com">Ian A. Design</a>
[edited by: adni18 at 8:53 pm (utc) on Sep. 18, 2004]
<head>
<script language=javascript>
<!--
var trip=-1;
function changeTarget() {
trip++;
var linknum=eval(document.body.getElementsByTagName("a").length);
document.body.getElementsByTagName("a")[trip].target='_blank';
if(trip<eval(linknum)-eval(1)){window.setTimeout("changeTarget()",0001)}
}
//-->
</script>
</head>
<BODY onLoad=changeTarget()>
<base target="_blank">
<a href="http://www.google.com">Google (New Window)</a>
<a href="http://www.dogpile.com">Dogpile (New Window)</a>
</BODY>
[edited by: adni18 at 9:15 pm (utc) on Sep. 18, 2004]
Here are some precisions :
- It must be valid XHTML Strict 1.0
- It must be global (all links in the page)
- No code must be added to links or group of links (plug&play)