Posted by: prajapatinilesh | September 14, 2007

open in a new browser window

function externalLinks() {
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” ) {
if ( anchor.getAttribute(“className”) )
{ anchor.target = anchor.getAttribute(“className”); }
else
{ anchor.target = “_blank”; }
}
}
}

//how to use…
<a href="link1.php" class="newWindow" rel="external"> Link 1 </a>
<a href="link2.php" > Link 2 </a>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: