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

Do to error codes you should use the old interface when attempting many of these tweaks to your template

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:

  1. 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.

    ReplyDelete
  2. 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.

    ReplyDelete
  3. Thanks a lot
    Very clever!

    ReplyDelete

Web Design Blogs PageRank