<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: jQuery tutorial: external links</title>
	<atom:link href="http://www.madeincima.it/en/articles/jquery-tutorial-external-links/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/</link>
	<description>Realizzazione siti internet, web app, logo design, brand identity</description>
	<lastBuildDate>Sat, 10 Dec 2011 23:22:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: zagi</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-838</link>
		<dc:creator>zagi</dc:creator>
		<pubDate>Mon, 16 May 2011 15:05:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-838</guid>
		<description>tnx for tutorial, its great!</description>
		<content:encoded><![CDATA[<p>tnx for tutorial, its great!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Terry</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-743</link>
		<dc:creator>Terry</dc:creator>
		<pubDate>Wed, 09 Feb 2011 22:12:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-743</guid>
		<description>I really like your accordion. Donation in the mail. :)

One question - what is the &quot;DS Store&quot; file?

Thanks - Terry</description>
		<content:encoded><![CDATA[<p>I really like your accordion. Donation in the mail. :)</p>
<p>One question &#8211; what is the &#8220;DS Store&#8221; file?</p>
<p>Thanks &#8211; Terry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Charmley</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-220</link>
		<dc:creator>Ryan Charmley</dc:creator>
		<pubDate>Thu, 16 Sep 2010 23:54:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-220</guid>
		<description>Very simple and well explained.  

I especially like how you mention the benefit of unobtrusive javascript, not only for validating strict XHTML, but for empowering clients using a CMS without the need of complicated tags and site-wide conformity.</description>
		<content:encoded><![CDATA[<p>Very simple and well explained.  </p>
<p>I especially like how you mention the benefit of unobtrusive javascript, not only for validating strict XHTML, but for empowering clients using a CMS without the need of complicated tags and site-wide conformity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery plugin: Easy List Splitter &#124; Andrea Cima Serniotti</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-218</link>
		<dc:creator>jQuery plugin: Easy List Splitter &#124; Andrea Cima Serniotti</dc:creator>
		<pubDate>Wed, 15 Sep 2010 13:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-218</guid>
		<description>[...] plugin Easy List Splitter e il nostro file JavaScript dal quale attiveremo il plugin. Se non sapete come fare a includere jQuery nelle vostre pagine trovate una spiegazione dettagliata nel mio primo tutorial per [...]</description>
		<content:encoded><![CDATA[<p>[...] plugin Easy List Splitter e il nostro file JavaScript dal quale attiveremo il plugin. Se non sapete come fare a includere jQuery nelle vostre pagine trovate una spiegazione dettagliata nel mio primo tutorial per [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery Plugin: Easy Accordion &#124; Andrea Cima Serniotti</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-214</link>
		<dc:creator>jQuery Plugin: Easy Accordion &#124; Andrea Cima Serniotti</dc:creator>
		<pubDate>Tue, 14 Sep 2010 13:50:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-214</guid>
		<description>[...] il plugin Easy Accordion e il nostro file JavaScript dal quale attiveremo il plugin. Se non sapete come fare a includere jQuery nelle vostre pagine trovate una spiegazione dettagliata nel mio primo tutorial per [...]</description>
		<content:encoded><![CDATA[<p>[...] il plugin Easy Accordion e il nostro file JavaScript dal quale attiveremo il plugin. Se non sapete come fare a includere jQuery nelle vostre pagine trovate una spiegazione dettagliata nel mio primo tutorial per [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery plugin: Easy Accordion &#124; Andrea Cima Serniotti</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-209</link>
		<dc:creator>jQuery plugin: Easy Accordion &#124; Andrea Cima Serniotti</dc:creator>
		<pubDate>Mon, 13 Sep 2010 15:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-209</guid>
		<description>[...] plugin and our Script file from where we&#8217;re going to call the plugin. If you do not know yet how to set up your jQuery environment, you can find a detailed explanation in my first jQuery tutorial, otherwise just keep [...]</description>
		<content:encoded><![CDATA[<p>[...] plugin and our Script file from where we&#8217;re going to call the plugin. If you do not know yet how to set up your jQuery environment, you can find a detailed explanation in my first jQuery tutorial, otherwise just keep [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaan</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-208</link>
		<dc:creator>Kaan</dc:creator>
		<pubDate>Tue, 07 Sep 2010 06:39:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-208</guid>
		<description>It works. Thank you.</description>
		<content:encoded><![CDATA[<p>It works. Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paulo</title>
		<link>http://www.madeincima.it/en/articles/jquery-tutorial-external-links/#comment-199</link>
		<dc:creator>Paulo</dc:creator>
		<pubDate>Sun, 06 Jun 2010 11:10:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.madeincima.eu/?p=192#comment-199</guid>
		<description>The jQuery you used to find all external links is a good reference! I started using it for a project I&#039;m doing, but caught some imperfections. For example, take the following EXTERNAL link:

http://www.externaldomain.com/?q=mydomain.com

Your code treats it as an INTERNAL link since your logic searches for &#039;your domain&#039; anywhere in the href value (since you use the &#039;asterisk equals&#039; operator). To be more robust you would have to find links that start with it by using &#039;carrot equals&#039; operator:

// needs to be repeated for &#039;https://&#039;
$(&quot;a[href^=&#039;http://&#039;]:not([href^=&#039;http://&quot;+location.hostname+&quot;&#039;]));

The code above works almost 100% of the time, but the domain for many sites includes the &#039;www.&#039; prefix and some don&#039;t. So if a link in your body was: &quot;http://www.mydomain.com/page.html&quot; but the address bar of your browser read: &quot;http://mydomain.com&quot;, then it would not match my jQuery above. So we need to be even more precise:

// again, needs to be repeated for &#039;https://&#039;
$(&quot;a[href^=&#039;http://&#039;]:not([href^=&#039;http://&quot;+location.hostname+&quot;&#039;]:not([href^=&#039;http://www.&quot;+location.hostname+&quot;&#039;]));

Personally, this is getting a bit too long, so I preferred to use regular expressions:

// for every link
$(&quot;a&quot;).each(function () {
	var href = $(this).attr(&quot;href&quot;);

	// remove the &#039;www.&#039; prefix from the href value (if it exists)
	var domain = location.hostname.replace(/^(www\.)?/, &quot;&quot;);

	// set up a regular expression that sees if a string starts with http[s]://[www.]mydomain.com
	var re = new RegExp(&quot;^https?:\\/\\/(www.)?&quot; + domain);

	// guaranteed to be an external link
	if (!re.test(href)) {
		$(this).attr(&quot;target&quot;, &quot;_blank&quot;).attr(&quot;title&quot;, &quot;Opens a new window&quot;);
	}
});</description>
		<content:encoded><![CDATA[<p>The jQuery you used to find all external links is a good reference! I started using it for a project I&#8217;m doing, but caught some imperfections. For example, take the following EXTERNAL link:</p>
<p><a href="http://www.externaldomain.com/?q=mydomain.com" rel="nofollow">http://www.externaldomain.com/?q=mydomain.com</a></p>
<p>Your code treats it as an INTERNAL link since your logic searches for &#8216;your domain&#8217; anywhere in the href value (since you use the &#8216;asterisk equals&#8217; operator). To be more robust you would have to find links that start with it by using &#8216;carrot equals&#8217; operator:</p>
<p>// needs to be repeated for &#8216;https://&#8217;<br />
$(&#8220;a[href^='http://']:not([href^='http://"+location.hostname+"']));</p>
<p>The code above works almost 100% of the time, but the domain for many sites includes the &#8216;www.&#8217; prefix and some don&#8217;t. So if a link in your body was: &#8220;http://www.mydomain.com/page.html&#8221; but the address bar of your browser read: &#8220;http://mydomain.com&#8221;, then it would not match my jQuery above. So we need to be even more precise:</p>
<p>// again, needs to be repeated for &#8216;https://&#8217;<br />
$(&#8220;a[href^='http://']:not([href^='http://"+location.hostname+"']:not([href^='http://www."+location.hostname+"']));</p>
<p>Personally, this is getting a bit too long, so I preferred to use regular expressions:</p>
<p>// for every link<br />
$(&#8220;a&#8221;).each(function () {<br />
	var href = $(this).attr(&#8220;href&#8221;);</p>
<p>	// remove the &#8216;www.&#8217; prefix from the href value (if it exists)<br />
	var domain = location.hostname.replace(/^(www\.)?/, &#8220;&#8221;);</p>
<p>	// set up a regular expression that sees if a string starts with http[s]://[www.]mydomain.com<br />
	var re = new RegExp(&#8220;^https?:\\/\\/(www.)?&#8221; + domain);</p>
<p>	// guaranteed to be an external link<br />
	if (!re.test(href)) {<br />
		$(this).attr(&#8220;target&#8221;, &#8220;_blank&#8221;).attr(&#8220;title&#8221;, &#8220;Opens a new window&#8221;);<br />
	}<br />
});</p>
]]></content:encoded>
	</item>
</channel>
</rss>

