<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ajgraham.com &#187; rel=&#8221;external&#8221;</title>
	<atom:link href="http://www.ajgraham.com/tag/relexternal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ajgraham.com</link>
	<description>web design, development and consultation in Prague</description>
	<lastBuildDate>Tue, 01 Nov 2011 22:16:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>JQuery: Open external links in new window</title>
		<link>http://www.ajgraham.com/2010/05/jquery-open-external-links-in-new-window/</link>
		<comments>http://www.ajgraham.com/2010/05/jquery-open-external-links-in-new-window/#comments</comments>
		<pubDate>Mon, 24 May 2010 18:00:29 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[rel="external"]]></category>

		<guid isPermaLink="false">http://www.ajgraham.com/?p=396</guid>
		<description><![CDATA[Finally got round to writing a small bit of code to automatically force anchor links to open in new windows if they are for different domains: $(document).ready(function() { var myDomain = ["www.ajgraham.com", "testing.ajgraham.com", "lifestream.ajgraham.com"]; //do NOT include the http:// pls! $("a[href^='http://']").each(function() { var slicedHref = $(this).attr('href').slice(7); var slashPosition = slicedHref.indexOf("/"); [...]]]></description>
			<content:encoded><![CDATA[<p>Finally got round to writing a small bit of code to automatically force anchor links to open in new windows if they are for different domains:</p>
<pre><code>$(document).ready(function() {
	var myDomain = ["www.ajgraham.com", "testing.ajgraham.com", "lifestream.ajgraham.com"]; //do NOT include the http:// pls!
	$("a[href^='http://']").each(function() {
		var slicedHref = $(this).attr('href').slice(7);
		var slashPosition = slicedHref.indexOf("/");
		if (slashPosition != -1) {
			slicedHref = slicedHref.slice(0,(slashPosition));
		}
		var matchCounter = 0;
		for (i=0;i&lt;myDomain.length;i++) {
			if (slicedHref.indexOf(myDomain[i]) == -1) {
				matchCounter++;
			}
		}
		if (matchCounter == myDomain.length) {
			$(this).attr("target","_blank").attr("rel","external").append("&lt;img class='new-window-link' alt='new window' src='http://www.ajgraham.com/wp-content/themes/ajgrahampro/images/external.png' style='padding-left:2px' /&gt;");
		}
	});
});</code></pre>
<p><a target="_blank" href="http://www.ajgraham.com/codestore/linksinnewwindow/anchorlinkstest.html">See Demo</a></p>
<p><a href="http://www.ajgraham.com/codestore/linksinnewwindow/newWindowLinks.zip">Download basic example</a></p>
<p>Just remember to change
<pre><code>var myDomain = ["www.ajgraham.com", "testing.ajgraham.com", "lifestream.ajgraham.com"];</code></pre>
<p> to your internal domain(s). You can use as many as you like, just don&#8217;t include the http:// bit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajgraham.com/2010/05/jquery-open-external-links-in-new-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

