<?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: Replacing target=”_blank” for Strict XHTML using JQuery (redux)</title>
	<atom:link href="http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/</link>
	<description>thoughts on web development and design</description>
	<lastBuildDate>Thu, 26 May 2011 13:12:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Leonid Sharlandzhiev</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-308</link>
		<dc:creator>Leonid Sharlandzhiev</dc:creator>
		<pubDate>Thu, 21 Apr 2011 12:44:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-308</guid>
		<description>@ Frank

The live() method has some flaws so you might need to use delegate() when working with arrays of elements like this:

$(&#039;.storycontent&#039;).delegate(&quot;a[href*=&#039;http://&#039;]:not([href*=&#039;&quot;+location.hostname+&quot;&#039;])&quot;, &#039;click&#039;, function() {
		window.open($(this).attr(&#039;href&#039;));
		return false;
	});</description>
		<content:encoded><![CDATA[<p>@ Frank</p>
<p>The live() method has some flaws so you might need to use delegate() when working with arrays of elements like this:</p>
<p>$(&#8216;.storycontent&#8217;).delegate(&#8220;a[href*='http://']:not([href*='"+location.hostname+"'])&#8221;, &#8216;click&#8217;, function() {<br />
		window.open($(this).attr(&#8216;href&#8217;));<br />
		return false;<br />
	});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: firebug</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-285</link>
		<dc:creator>firebug</dc:creator>
		<pubDate>Tue, 11 Jan 2011 13:41:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-285</guid>
		<description>$(document).ready(function(){
	$(&#039;a[rel*=external]&#039;).click(function(){
        this.target= &quot;_blank&quot;;
    });</description>
		<content:encoded><![CDATA[<p>$(document).ready(function(){<br />
	$(&#8216;a[rel*=external]&#8216;).click(function(){<br />
        this.target= &#8220;_blank&#8221;;<br />
    });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-269</link>
		<dc:creator>Brendan</dc:creator>
		<pubDate>Fri, 03 Sep 2010 15:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-269</guid>
		<description>If you don&#039;t want to use _target at all (cause it is kinda cheating, isn&#039;t it?), this is what I did:

$(&quot;a.pdf&quot;).mouseover(function() {
    pdfLink = this.href;
	$(this).attr(&quot;href&quot;,&quot;#&quot;);
});

$(&quot;a.pdf&quot;).click(function() { window.open(pdfLink); });

$(&quot;a.pdf&quot;).mouseout(function() {
	$(this).attr(&quot;href&quot;,pdfLink);
	pdfLink = &quot;&quot;;
});

You pick your target (for me, it was things that linked out to PDFs, so I had a class called &#039;pdf&#039;). On mouseover, you put the href into a variable, you strip the href from the &lt;a&gt; tag so that the link doesn&#039;t open in the parent window as well. On click, you open that variable in the new window. On mouseout, put the variable back in the href.

Since we&#039;re using JavaScript anyways, it&#039;s a solution that avoids _target completely, and it allows for a functioning link if the user has JavaScript turned off.

Hope it helps someone!

Cheers,
Brendan</description>
		<content:encoded><![CDATA[<p>If you don&#8217;t want to use _target at all (cause it is kinda cheating, isn&#8217;t it?), this is what I did:</p>
<p>$(&#8220;a.pdf&#8221;).mouseover(function() {<br />
    pdfLink = this.href;<br />
	$(this).attr(&#8220;href&#8221;,&#8221;#&#8221;);<br />
});</p>
<p>$(&#8220;a.pdf&#8221;).click(function() { window.open(pdfLink); });</p>
<p>$(&#8220;a.pdf&#8221;).mouseout(function() {<br />
	$(this).attr(&#8220;href&#8221;,pdfLink);<br />
	pdfLink = &#8220;&#8221;;<br />
});</p>
<p>You pick your target (for me, it was things that linked out to PDFs, so I had a class called &#8216;pdf&#8217;). On mouseover, you put the href into a variable, you strip the href from the <a> tag so that the link doesn&#8217;t open in the parent window as well. On click, you open that variable in the new window. On mouseout, put the variable back in the href.</p>
<p>Since we&#8217;re using JavaScript anyways, it&#8217;s a solution that avoids _target completely, and it allows for a functioning link if the user has JavaScript turned off.</p>
<p>Hope it helps someone!</p>
<p>Cheers,<br />
Brendan</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-261</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Mon, 05 Jul 2010 13:47:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-261</guid>
		<description>I find this nice way to do it:

$(&quot;a[rel*=external]&quot;).attr( &quot;target&quot;, &quot;_blank&quot; );

It&#039;s valid, since target is still an attribute in the DOM definition.</description>
		<content:encoded><![CDATA[<p>I find this nice way to do it:</p>
<p>$(&#8220;a[rel*=external]&#8220;).attr( &#8220;target&#8221;, &#8220;_blank&#8221; );</p>
<p>It&#8217;s valid, since target is still an attribute in the DOM definition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-258</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Tue, 15 Jun 2010 14:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-258</guid>
		<description>Remember - if you happen to generate an external link or two dynamically after the page loads, the new link won&#039;t &quot;pop&quot; into a new window - unless you bind the click event to the external links with live().

$(&#039;a[rel*=external]&#039;).live(&#039;click&#039;, function(){
	window.open($(this).attr(&#039;href&#039;));
	return false;
});

This ensures that any new elements are bound to the modified click event, too.</description>
		<content:encoded><![CDATA[<p>Remember &#8211; if you happen to generate an external link or two dynamically after the page loads, the new link won&#8217;t &#8220;pop&#8221; into a new window &#8211; unless you bind the click event to the external links with live().</p>
<p>$(&#8216;a[rel*=external]&#8216;).live(&#8216;click&#8217;, function(){<br />
	window.open($(this).attr(&#8216;href&#8217;));<br />
	return false;<br />
});</p>
<p>This ensures that any new elements are bound to the modified click event, too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan Carroll</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-248</link>
		<dc:creator>Evan Carroll</dc:creator>
		<pubDate>Thu, 06 May 2010 16:33:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-248</guid>
		<description>This is my favorite solution to this problem, because it uses JQuery, and doesn&#039;t assume the XHTML capable browser has implemented HTML4 &quot;target&quot; attribute on links.</description>
		<content:encoded><![CDATA[<p>This is my favorite solution to this problem, because it uses JQuery, and doesn&#8217;t assume the XHTML capable browser has implemented HTML4 &#8220;target&#8221; attribute on links.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-244</link>
		<dc:creator>Keith</dc:creator>
		<pubDate>Fri, 16 Apr 2010 00:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-244</guid>
		<description>Man, that is sweet.  Thanks!</description>
		<content:encoded><![CDATA[<p>Man, that is sweet.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Scheetz</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-184</link>
		<dc:creator>Justin Scheetz</dc:creator>
		<pubDate>Fri, 21 Aug 2009 13:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-184</guid>
		<description>This will search your entire page for external links and make them open in a new window. Try it out!

$(function() {
		$(&quot;a[href*=&#039;http://&#039;]:not([href*=&#039;&quot;+location.hostname+&quot;&#039;])&quot;).click( function() {
		window.open(this.href);
		return false;
	});
});</description>
		<content:encoded><![CDATA[<p>This will search your entire page for external links and make them open in a new window. Try it out!</p>
<p>$(function() {<br />
		$(&#8220;a[href*='http://']:not([href*='"+location.hostname+"'])&#8221;).click( function() {<br />
		window.open(this.href);<br />
		return false;<br />
	});<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zmpl</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-180</link>
		<dc:creator>zmpl</dc:creator>
		<pubDate>Tue, 07 Jul 2009 02:11:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-180</guid>
		<description>Another possible attribute name is

xlink:show=&quot;new&quot;

from the XLink spec.</description>
		<content:encoded><![CDATA[<p>Another possible attribute name is</p>
<p>xlink:show=&#8221;new&#8221;</p>
<p>from the XLink spec.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: martin(ish) &#167; Blog: Post: Open External Links in a New Window Using jQuery</title>
		<link>http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/comment-page-1/#comment-179</link>
		<dc:creator>martin(ish) &#167; Blog: Post: Open External Links in a New Window Using jQuery</dc:creator>
		<pubDate>Mon, 06 Jul 2009 02:21:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.badlydrawntoy.com/?p=177#comment-179</guid>
		<description>[...] second solution I came across fixed some of the issues of the first by re&#8208;writing the regex to account for [...]</description>
		<content:encoded><![CDATA[<p>[...] second solution I came across fixed some of the issues of the first by re&#8208;writing the regex to account for [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

