Yes, you can do this:
function externalLinks() {
if (!document.getElementsByTa
gName) return;
var anchors = document.getElementsByTagN
ame("a");
for (var i=0; i<anchors.length; i++) {
if(!anchors[i].href.match(
'
www.example.com/'))
{anchors[i].target = "_blank";}
if(!anchors[i].href.match(
'
www.example1.com/')
)
{anchors[i].target = "_blank";}
if(!anchors[i].href.match(
'
www.example2.com/')
)
{anchors[i].target = "_blank";}
if(!anchors[i].href.match(
'
www.example3.com/')
)
{anchors[i].target = "_blank";}
}
}
window.onload = externalLinks;
or
function externalLinks() {
if (!document.getElementsByTa
gName) return;
var anchors = document.getElementsByTagN
ame("a");
for (var i=0; i<anchors.length; i++) {
if(!anchors[i].href.search
('
www.example') > -1)
{anchors[i].target = "_blank";}
}
}
window.onload = externalLinks;