<?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>Reader.ws &#187; Tips</title>
	<atom:link href="http://reader.ws/category/tips/feed" rel="self" type="application/rss+xml" />
	<link>http://reader.ws</link>
	<description>Webmaster tutorials, tips, tricks, and tools</description>
	<lastBuildDate>Tue, 21 Jun 2011 07:03:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using the Target Attribute in Xhtml</title>
		<link>http://reader.ws/tips/using-the-target-attribute-in-xhtml</link>
		<comments>http://reader.ws/tips/using-the-target-attribute-in-xhtml#comments</comments>
		<pubDate>Sun, 18 Jul 2010 15:39:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[anchor tag]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[new tab]]></category>
		<category><![CDATA[new window]]></category>
		<category><![CDATA[script tag]]></category>
		<category><![CDATA[target]]></category>
		<category><![CDATA[xhtml]]></category>
		<category><![CDATA[_blank]]></category>

		<guid isPermaLink="false">http://reader.ws/?p=73</guid>
		<description><![CDATA[The target attribute &#119;&#105;&#116;&#104; &#97; value &#111;&#102; &#8220;_blank&#8221; &#105;&#115; usually &#117;&#115;&#101;&#100; &#116;&#111; tell &#116;&#104;&#101; browser &#116;&#111; open &#97; &#110;&#101;&#119; window / tab &#119;&#104;&#101;&#110; &#97; link &#105;&#115; clicked. Unfortunately &#116;&#104;&#105;&#115; attribute &#105;&#115; &#110;&#111;&#116; defined &#105;&#110; XHML &#115;&#111; &#105;&#116; &#119;&#105;&#108;&#108; cause &#116;&#104;&#101; page &#116;&#111; fail validation. To &#103;&#101;&#116; &#97;&#114;&#111;&#117;&#110;&#100; &#116;&#104;&#105;&#115; &#119;&#101; &#99;&#97;&#110; &#117;&#115;&#101; &#97; &#115;&#109;&#97;&#108;&#108; snippet &#111;&#102; <a href='http://reader.ws/tips/using-the-target-attribute-in-xhtml'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The target attribute &#119;&#105;&#116;&#104; &#97; value &#111;&#102; &#8220;_blank&#8221; &#105;&#115; usually &#117;&#115;&#101;&#100; &#116;&#111; tell &#116;&#104;&#101; browser &#116;&#111; open &#97; &#110;&#101;&#119; window / tab &#119;&#104;&#101;&#110; &#97; link &#105;&#115; clicked. Unfortunately &#116;&#104;&#105;&#115; attribute &#105;&#115; &#110;&#111;&#116; defined &#105;&#110; XHML &#115;&#111; &#105;&#116; &#119;&#105;&#108;&#108; cause &#116;&#104;&#101; page &#116;&#111; fail validation. To &#103;&#101;&#116; &#97;&#114;&#111;&#117;&#110;&#100; &#116;&#104;&#105;&#115; &#119;&#101; &#99;&#97;&#110; &#117;&#115;&#101; &#97; &#115;&#109;&#97;&#108;&#108; snippet &#111;&#102; JavaScript &#97;&#110;&#100; &#116;&#104;&#101; onclick event handler &#116;&#111; accomplish &#116;&#104;&#101; task. Although &#116;&#104;&#105;&#115; &#109;&#105;&#103;&#104;&#116; sound &#108;&#105;&#107;&#101; &#97; difficult &#111;&#114; confusing task, &#105;&#116; &#105;&#115; not.<br />
First &#119;&#101; &#110;&#101;&#101;&#100; &#116;&#111; define &#97; script block &#105;&#110; &#116;&#104;&#101; html header block &#111;&#102; &#116;&#104;&#101; page. This block &#99;&#97;&#110; &#98;&#101; locate anywhere between &#116;&#104;&#101; &lt;head&gt; tag &#97;&#110;&#100; &#116;&#104;&#101; &lt;/head&gt; tag. &#97;&#110;&#100; looks &#108;&#105;&#107;&#101; this.</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
&lt;/script&gt;</p>
<p>Once &#119;&#101; &#104;&#97;&#118;&#101; &#116;&#104;&#105;&#115; &#115;&#101;&#116; &#117;&#112; &#119;&#101; &#104;&#97;&#118;&#101; &#116;&#111; create &#97; javascript function &#116;&#111; call &#119;&#105;&#116;&#104; &#116;&#104;&#101; event handler &#119;&#104;&#105;&#99;&#104; &#119;&#101; &#119;&#105;&#108;&#108; &#103;&#101;&#116; &#116;&#111; &#105;&#110; &#97; minute. The function &#119;&#105;&#108;&#108; &#98;&#101; receiving 1 agument &#116;&#104;&#97;&#116; needs &#116;&#111; &#98;&#101; processed. The function &#119;&#105;&#108;&#108; &#108;&#111;&#111;&#107; &#108;&#105;&#107;&#101; this</p>
<p>function newWin(link) {<br />
link.target=&#8221;_blank&#8221;;<br />
}</p>
<p>Yup &#116;&#104;&#97;&#116; &#105;&#115; it. The whole function. Now &#116;&#111; explain &#97; little. The argument &#110;&#97;&#109;&#101; I choose &#119;&#97;&#115; link &#98;&#117;&#116; &#99;&#111;&#117;&#108;&#100; &#98;&#101; &#97;&#110;&#121; &#110;&#97;&#109;&#101; &#121;&#111;&#117; &#119;&#97;&#110;&#116; &#105;&#116; &#116;&#111; be. Not &#116;&#111; &#103;&#101;&#116; &#121;&#111;&#117; &#116;&#111; confused I &#119;&#105;&#108;&#108; &#110;&#111;&#116; &#103;&#111; &#105;&#110;&#116;&#111; &#109;&#117;&#99;&#104; detail &#97;&#98;&#111;&#117;&#116; link &#98;&#101;&#105;&#110;&#103; &#97; javascript object &#102;&#111;&#114; &#116;&#104;&#101; link &#119;&#101; define &#105;&#110; &#116;&#104;&#101; xhtml. The body &#111;&#102; &#116;&#104;&#101; function &#104;&#97;&#115; &#111;&#110;&#101; assignment command &#105;&#110; it. We &#97;&#114;&#101; assigning &#8220;_blank&#8221; to  &#116;&#104;&#101; links target attribute. Then &#119;&#101; close &#111;&#102;&#102; &#116;&#104;&#101; function. &#116;&#104;&#101; whole script block &#115;&#104;&#111;&#117;&#108;&#100; &#108;&#111;&#111;&#107; &#108;&#105;&#107;&#101; &#116;&#104;&#105;&#115; now.</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function newWin(link) {<br />
link.target=&#8221;_blank&#8221;;<br />
}<br />
&lt;/script&gt;</p>
<p>Now &#119;&#101; &#103;&#111; ahead &#97;&#110;&#100; &#108;&#111;&#111;&#107; &#97;&#116; &#116;&#104;&#101; anchor tag &#97;&#110;&#100; building &#116;&#104;&#101; link.</p>
<p>&lt;a href=&#8221;http://reader.ws&#8221; onclick=&#8221;newWin(this)&#8221;&gt;Click Here&lt;/a&gt;<br />
Try &#105;&#116; &#111;&#117;&#116; &#102;&#111;&#114; yourself &#98;&#121; <a onclick="newWin(this)" href="http://reader.ws">Clicking Here</a></p>
<p>This &#105;&#115; &#106;&#117;&#115;&#116; &#97; plain &#111;&#108;&#100; anchor tag &#116;&#104;&#97;&#116; points &#116;&#111; &#109;&#121; main page &#119;&#105;&#116;&#104; &#116;&#104;&#101; exception &#111;&#102; &#116;&#104;&#101; onclick handler. Simply &#112;&#117;&#116; &#119;&#104;&#101;&#110; &#121;&#111;&#117; click &#111;&#110; &#116;&#104;&#101; link text &#8220;Click Here&#8221; &#105;&#116; &#119;&#105;&#108;&#108; open &#97; &#110;&#101;&#119; window /tab &#105;&#110; &#121;&#111;&#117;&#114; browser depending &#111;&#110; &#104;&#111;&#119; &#121;&#111;&#117; &#104;&#97;&#118;&#101; &#116;&#104;&#97;&#116; &#115;&#101;&#116; up. To explain, &#119;&#101; simply call &#116;&#104;&#101; newWin javascript function &#119;&#105;&#116;&#104; &#116;&#104;&#101; &#8220;this&#8221; argument. Now &#105;&#110; case &#121;&#111;&#117; &#97;&#114;&#101; wondering &#119;&#104;&#97;&#116; &#8220;this&#8221; means. It &#105;&#115; &#117;&#115;&#101;&#100; &#105;&#110; object oriented programming languages &#116;&#111; represent &#116;&#104;&#101; current object. In &#116;&#104;&#105;&#115; case &#116;&#104;&#101; anchor tag.</p>
<p>As &#97;&#110; Alternative &#119;&#97;&#121; &#111;&#102; setting &#117;&#112; &#116;&#104;&#101; link without &#116;&#104;&#101; function &#105;&#110; &#116;&#104;&#101; header &#105;&#115; &#116;&#111; &#106;&#117;&#115;&#116; &#112;&#117;&#116; &#116;&#104;&#101; javascript directly &#105;&#110;&#116;&#111; &#116;&#104;&#101; value &#111;&#102; &#116;&#104;&#101; onclick handler. If &#121;&#111;&#117; decide &#116;&#111; &#100;&#111; &#105;&#116; &#116;&#104;&#105;&#115; &#119;&#97;&#121; &#116;&#104;&#101;&#110; &#121;&#111;&#117; &#115;&#104;&#111;&#117;&#108;&#100; add &#116;&#104;&#101; &#8220;return true&#8221; statement &#116;&#111; &#116;&#104;&#101; end. The code &#119;&#105;&#108;&#108; &#108;&#111;&#111;&#107; &#108;&#105;&#107;&#101; &#116;&#104;&#105;&#115; &lt;a onclick=&#8221;this.target=&#8217;_blank;return true&#8217;&#8221; href=&#8221;http://reader.ws&#8221;&gt;Clicking Here&lt;/a&gt; &#97;&#110;&#100; &#121;&#111;&#117; &#99;&#97;&#110; try &#105;&#116; &#98;&#121; <a onclick="this.target='_blank;return true'" href="http://reader.ws">Clicking Here</a></p>
<p>That &#105;&#115; &#97;&#108;&#108; &#116;&#104;&#101;&#114;&#101; &#105;&#115; &#116;&#111; it. You &#99;&#97;&#110; &#115;&#101;&#116; &#117;&#112; &#97;&#115; &#109;&#97;&#110;&#121; links &#111;&#110; &#116;&#104;&#101; page &#121;&#111;&#117; &#119;&#97;&#110;&#116; &#108;&#105;&#107;&#101; &#116;&#104;&#105;&#115; &#97;&#110;&#100; &#116;&#104;&#101;&#121; &#119;&#105;&#108;&#108; &#97;&#108;&#108; work. I side note here. If &#121;&#111;&#117; happen &#116;&#111; &#104;&#97;&#118;&#101; &#97; javascript file linked &#116;&#111; &#121;&#111;&#117;&#114; page feel free &#116;&#111; drop &#116;&#104;&#101; function &#105;&#110; &#116;&#104;&#101;&#114;&#101; instead &#111;&#102; &#105;&#110; &#116;&#104;&#101; html header block, &#97;&#115; &#116;&#104;&#97;&#116; &#119;&#105;&#108;&#108; work &#106;&#117;&#115;&#116; fine &#97;&#115; &#108;&#111;&#110;&#103; &#97;&#115; &#116;&#104;&#101; function &#105;&#115; defined before &#121;&#111;&#117; call &#105;&#116; &#102;&#114;&#111;&#109; &#97; link &#121;&#111;&#117; &#97;&#114;&#101; &#105;&#110; great shape.</p>
<p>If &#121;&#111;&#117; &#108;&#105;&#107;&#101; &#116;&#104;&#105;&#115; tip feel free &#116;&#111; leave &#97; comment</p>
<script src='http://www.automatedtraffic.com/auto_ads/preview.php?displayLink=yes&project_id=3001' language='javascript' type='text/javascript'></script>]]></content:encoded>
			<wfw:commentRss>http://reader.ws/tips/using-the-target-attribute-in-xhtml/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

