Masukkan E-Mail untuk Berlangganan:


4.03.2012

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.

Source : http://www.tweakmyblogger.com/2011/09/opening-external-links-in-new-window.html
read more »»  

My Pet