Open links in a new window or in a new tab
There are following ways to achieve that :
1. Specify target in anchor tag.
Its works for single link.
2. For All links in a page : Specify target in a tag.
3. Using Java Script:
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.onclick = "return ! window.open(this.href);"
}
}
}
window.onload = externalLinks;
Some page
Thanx
1. Specify target in anchor tag.
Its works for single link.
2. For All links in a page : Specify target in a tag.
3. Using Java Script:
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.onclick = "return ! window.open(this.href);"
}
}
}
window.onload = externalLinks;
Some page
Thanx
Comments
Post a Comment