Translate This Blog
Remember To Always Back Up Your Template Before Attempting Any Of The Tweaks On This Site

Opening External Links In New Window

Their are a few codes out their that will open links in a new window but for most people they just want external links to be the target. With this script below you can open external links in a new window without implanting multiple codes in every link. This will only work if the viewer has JavaScript enabled!

Place this code just under the <head> tag in your template.
<script type='text/javascript'>

//<![CDATA[

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=anchors.length-1; i>=0; i--) {
var anchor = anchors[i];
if (anchor.href && anchor.href.substr(0,Number) != "Homepage URL")
anchor.target = "_blank";
}
}
window.onload = externalLinks;

//]]>

</script>


The red text needs to be the link to your homepage (exactly).

The blue text should be the number of the characters (including http:// and .com) that you just placed in for the red text.

3 comments:

Michelle and Cindy said...

I am probably missing something - I know how to open in a New Window in or from the post itself if required but how to do this in the side panel using: Configure Link List?

In this case - if you look - it is URL of Canadian Company of Pilgrims.

Thanks.

AiresOFwar said...

I could go over how to do that but my buddy has a blog with a tutorial that covers opening link list in a new window. Click here to see it and scroll to the bottom.

MIKIDE said...

Thanks a lot
Very clever!

Post a Comment

Please don't post hyperlinked text within the comment box! It will not be published and you will be marked as spam.

Web Design Blogs PageRank