Enhance External Links
11
Enhance External Links
var enhanceLinks =
{
initialise: function()
{
// Check the browser can understand this script:
if (!document.getElementsByTagName)
return;
var pageLinks = document.getElementsByTagName('a');
for (var i = 0; i < pageLinks.length; i++)
{
// Check if the link leads outside the parent domain:
if (pageLinks[i].href.indexOf('http://' + window.location.hostname) == -1)
{
// Don't write over any existing class names:
pageLinks[i].className += ' external';
pageLinks[i].title = 'This is an external link that will open a new window (' + pageLinks[i].href + ')';
pageLinks[i].onclick = enhanceLinks.popup;
}
}
},
popup: function()
{
window.open(this.href, 'flPopup', '');
return false;
}
}
{
initialise: function()
{
// Check the browser can understand this script:
if (!document.getElementsByTagName)
return;
var pageLinks = document.getElementsByTagName('a');
for (var i = 0; i < pageLinks.length; i++)
{
// Check if the link leads outside the parent domain:
if (pageLinks[i].href.indexOf('http://' + window.location.hostname) == -1)
{
// Don't write over any existing class names:
pageLinks[i].className += ' external';
pageLinks[i].title = 'This is an external link that will open a new window (' + pageLinks[i].href + ')';
pageLinks[i].onclick = enhanceLinks.popup;
}
}
},
popup: function()
{
window.open(this.href, 'flPopup', '');
return false;
}
}
Comments
Voting
Votes Up
ASmith
BrandonReese
ColdKeyboard
dannyboy
i_kenneth
Pio
RatNuShock
SCoon
SecondV
sundaramkumar
wiz1705






There are currently no comments for this snippet.