<?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>ieatpenguin &#187; Javascript</title>
	<atom:link href="http://r-dunn.co.uk/ieatpenguin/category/computing/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://r-dunn.co.uk/ieatpenguin</link>
	<description>Reductio ad absurdum!</description>
	<lastBuildDate>Mon, 23 Jan 2012 12:11:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Emulating target=&#8221;_blank&#8221; in XHTML</title>
		<link>http://r-dunn.co.uk/ieatpenguin/computing/javascript/emulating-target_blank-in-xhtml/</link>
		<comments>http://r-dunn.co.uk/ieatpenguin/computing/javascript/emulating-target_blank-in-xhtml/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 15:00:38 +0000</pubDate>
		<dc:creator>Russell</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://r-dunn.co.uk/ieatpenguin/?p=459</guid>
		<description><![CDATA[A friend was having trouble with this earlier today so thought I&#8217;d post the answer. Whether or not you consider this cheating (I don&#8217;t), it&#8217;s the only way to get a link to open in a new window and remain &#8230; <a href="http://r-dunn.co.uk/ieatpenguin/computing/javascript/emulating-target_blank-in-xhtml/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>A friend was having trouble with this earlier today so thought I&#8217;d post the answer. Whether or not you consider this cheating (I don&#8217;t), it&#8217;s the only way to get a link to open in a new window <span style="text-decoration: line-through;">and remain valid XHTML code</span>, and be valid in the upcoming XHTML 4.0. It is still valid in XHTML 1.0.</p>
<p>The reason this was taken out in XHTML 4.0, is that the W3 see a new window as no longer being the concern of the current document &#8211; and so not valid XHTML, as therein lies the language&#8217;s concern.</p>
<p>Anyway, to the solution, a simple bit of Javascript:</p>
<blockquote>
<pre>function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i&lt;anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &amp;&amp;
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;</pre>
</blockquote>
<p>Place this in a .js file along with the rest of your .html files, and then call it in the head of the document thus:</p>
<blockquote>
<pre>&lt;script type="text/javascript" src="xhtmllinks.js"&gt;&lt;/script&gt;</pre>
</blockquote>
<p>And then edit your links to call the script every time they are clicked:</p>
<blockquote>
<pre>&lt;a href="http://www.r-dunn.co.uk/ieatpenguin/" rel="external"&gt;i eat penguin&lt;/a&gt;</pre>
</blockquote>
<div class="shr-publisher-459"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://r-dunn.co.uk/ieatpenguin/computing/javascript/emulating-target_blank-in-xhtml/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using different CSS styles in Javascript enabled browsers</title>
		<link>http://r-dunn.co.uk/ieatpenguin/computing/javascript/using-different-css-styles-in-javascript-enabled-browsers/</link>
		<comments>http://r-dunn.co.uk/ieatpenguin/computing/javascript/using-different-css-styles-in-javascript-enabled-browsers/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 12:58:14 +0000</pubDate>
		<dc:creator>Russell</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://r-dunn.co.uk/ieatpenguin/?p=389</guid>
		<description><![CDATA[This is an easy to implement, yet useful and possibly powerful technique. Using different CSS rules in JavaScript enabled browsers lets you customise your website styles for JS enabled and disabled browsers using only CSS. Thus: you leave the concerns &#8230; <a href="http://r-dunn.co.uk/ieatpenguin/computing/javascript/using-different-css-styles-in-javascript-enabled-browsers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This is an easy to implement, yet useful and possibly powerful technique. Using different CSS rules in JavaScript enabled browsers lets you customise your website styles for JS enabled and disabled browsers using only CSS.</p>
<p>Thus: you leave the concerns of styling strictly to CSS, and the business aspect of the website to the javascript.</p>
<p>All you need to do is to add some class or id to body element using JavaScript to specify that JavaScript is available. Then define two rules in your CSS file(s) for JS enabled and disabled browsers.</p>
<p><strong>Here is an example for a JavaScript enabled browser:</strong></p>
<blockquote>
<pre class="prettyprint lang-js">document.getElementsByTagName("body")[0].setAttribute("class", "js");</pre>
</blockquote>
<p><strong>And in your CSS file:</strong></p>
<blockquote>
<pre class="prettyprint lang-css">.aClass{
    display:block;
}
.js .aClass{
    display:none;
}</pre>
</blockquote>
<p>Why do I need to have a different CSS styles for jQuery enabled browser you might ask. Well, consider you have a drop-down menu on your website’s sidebar and you would like to use Javascript to make it drop down on mouse hover. This would render the element not accessible if the user has disabled Javascript on his/her browsers.</p>
<div class="shr-publisher-389"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://r-dunn.co.uk/ieatpenguin/computing/javascript/using-different-css-styles-in-javascript-enabled-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

