<?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>Web Design - SEO - Technology ReviewsPosts tagged New Window</title>
	<atom:link href="http://www.bliznet.com/tag/new-window/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bliznet.com</link>
	<description>Internet marketing and web design experience.</description>
	<lastBuildDate>Sat, 07 Jan 2012 21:44:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Target Attribute and Strict XHTML</title>
		<link>http://www.bliznet.com/the-target-attribute-and-strict-xhtml/</link>
		<comments>http://www.bliznet.com/the-target-attribute-and-strict-xhtml/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 18:22:02 +0000</pubDate>
		<dc:creator>Kyle Blizzard</dc:creator>
				<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[New Window]]></category>
		<category><![CDATA[Target]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.bliznet.com/?p=102</guid>
		<description><![CDATA[How to open links in a new window because target is not a valid attribute in XHTML 1.0 Strict.]]></description>
			<content:encoded><![CDATA[<p>So, you&#8217;ve decided to start creating your web sites with valid strict XHTML 1.0 and CSS. Your client wants a &#8220;links&#8221; page containing none other than links to other web sites. So you oblige and, to keep your client&#8217;s visitors on his site, you make the links open in a new window. So you throw in <code>target="blank"</code> and you&#8217;re done. Just run it through the W3 validator&#8230;</p>
<p><em>There is no attribute &#8220;target&#8221;? What gives?!</em></p>
<p>Yes, indeed, <code>target</code> is not a valid attribute in XHTML 1.0 Strict. There&#8217;s really only one way around it of which I&#8217;m aware, and that&#8217;s by using Javascript. My preferred method is as follows:</p>
<div class="code-example"><code>&lt;a href="http://www.bliznet.com/" onclick="window.open(this.href, 'OffSite').focus(); return false;"&gt;</code></div>
<p>This opens the URL in a new window and brings it into focus if the user had previously opened an &#8220;OffSite&#8221; window and didn&#8217;t close it.</p>
<p>You would still put the desired URL in the <code>href</code> attribute just like with any hyperlink. That way, if the visitor for some reason has Javascript disabled, the link still functions correctly. It just wouldn&#8217;t open in a new window.</p>
<p>One caveat though—in Firefox 2 and later with default settings, this code causes the linked site to open in a new tab, not a new window. If you find this to be a problem, there is a way around it, and that&#8217;s by adding the window options parameter such as:</p>
<div class="code-example"><code>&lt;a href="http://www.bliznet.com/" onclick="window.open(this.href, 'OffSite', 'directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes').focus(); return false;"&gt;</code></div>
<p>Those are all the options required to make the window appear normally with default tool and menu bars—kind of a pain. At this point, you may want to move the code into an external Javascript file. The function I use typically looks like the following:</p>
<div class="code-example"><code>function OpenOffSite(a)<br />
{<br />
window.open(a.href, "OffSite", "directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes").focus();<br />
return false;<br />
}</code></div>
<p>Then the <code>onclick</code> attribute of your anchor would look like so:</p>
<div class="code-example"><code>&lt;a href="http://www.bliznet.com/" onclick="return OpenOffSite(this);"&gt;</code></div>
<p>Your links now open in a new window! Welcome to the world of XHTML conformity. <img src='http://www.bliznet.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.bliznet.com/the-target-attribute-and-strict-xhtml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

