<?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: Open A New Browser Window</title>
	<atom:link href="http://www.elanman.co.uk/2009/05/open-a-new-browser-window/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elanman.co.uk/2009/05/open-a-new-browser-window/</link>
	<description>ElanMan&#039;s Code Snippets</description>
	<lastBuildDate>Tue, 24 Aug 2010 07:35:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Kit Barker</title>
		<link>http://www.elanman.co.uk/2009/05/open-a-new-browser-window/comment-page-1/#comment-77</link>
		<dc:creator>Kit Barker</dc:creator>
		<pubDate>Thu, 07 May 2009 11:36:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.elanman.co.uk/?p=808#comment-77</guid>
		<description>I don&#039;t really like opening new browser windows at all to be honest.

It annoys me when a site I&#039;m looking at opens new windows. I like to control whether a link is opened in a new tab, window or in the same window. All browsers let you do this, such as Command+Click in Safari.

Personally I&#039;d rather try and teach people to learn to use there browser properly. The same applies with printing, back buttons and such like.

That said, you have to do what clients want and I get plenty of clients moaning if external links open in &quot;their&quot; window!</description>
		<content:encoded><![CDATA[<p>I don&#8217;t really like opening new browser windows at all to be honest.</p>
<p>It annoys me when a site I&#8217;m looking at opens new windows. I like to control whether a link is opened in a new tab, window or in the same window. All browsers let you do this, such as Command+Click in Safari.</p>
<p>Personally I&#8217;d rather try and teach people to learn to use there browser properly. The same applies with printing, back buttons and such like.</p>
<p>That said, you have to do what clients want and I get plenty of clients moaning if external links open in &#8220;their&#8221; window!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Mason</title>
		<link>http://www.elanman.co.uk/2009/05/open-a-new-browser-window/comment-page-1/#comment-74</link>
		<dc:creator>Rob Mason</dc:creator>
		<pubDate>Tue, 05 May 2009 11:55:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.elanman.co.uk/?p=808#comment-74</guid>
		<description>I am anal about using transitional - use strict! Good skills here, as it took me ages to find a suitable solution that a) worked well and b) I understood. I found one (can&#039;t remember where) that didn&#039;t add a target=&quot; _blank&quot; into the link, instead used a similar approach to pop-ups:

&lt;code&gt;
function externalLinks() {
  //we need getElementsByTagName for this to work
  if (!document.getElementsByTagName) return;
 
  //get all the anchors within the document
  var anchors = document.getElementsByTagName(&quot;a&quot;);
  for (var i=0; i&lt;anchors.length; i++) { //loop through all the anchors
    var anchor = anchors[i];
   
    //check to make sure that we have a href, so its a real hyperlink
    //and make sure that we have a ref and its set to external
    if (anchor.getAttribute(&quot;href&quot;) &amp;&amp; anchor.getAttribute(&quot;rel&quot;) == &quot;external&quot;) {
   
      //assign the dynamic function to the onclick event.
      anchor.onclick = function(x) {
        //store the variable so that we can actually use it within each function
        var p = x;
        return function() {
          var w = window.open(p); //try and open up a new window with the url
          if(!w) { //check to see if the window opened
            //let the user know that a window didnt open
            alert(&quot;A popup blocker seems to have blocked the window from opening&quot;);
          }
         
          //return false to make sure the browser doesnt navigate away in the current window also
          return false;
        }
      }(anchor.getAttribute(&quot;href&quot;)); //pass through the href for this anchor
    }
  }
}

//make sure we only set everything up on load
//after the DOM has been inited
window.onload = externalLinks;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I am anal about using transitional &#8211; use strict! Good skills here, as it took me ages to find a suitable solution that a) worked well and b) I understood. I found one (can&#8217;t remember where) that didn&#8217;t add a target=&#8221; _blank&#8221; into the link, instead used a similar approach to pop-ups:</p>
<p><code><br />
function externalLinks() {<br />
  //we need getElementsByTagName for this to work<br />
  if (!document.getElementsByTagName) return;</p>
<p>  //get all the anchors within the document<br />
  var anchors = document.getElementsByTagName("a");<br />
  for (var i=0; i&lt;anchors.length; i++) { //loop through all the anchors<br />
    var anchor = anchors[i];</p>
<p>    //check to make sure that we have a href, so its a real hyperlink<br />
    //and make sure that we have a ref and its set to external<br />
    if (anchor.getAttribute("href") &amp;&amp; anchor.getAttribute("rel") == "external") {</p>
<p>      //assign the dynamic function to the onclick event.<br />
      anchor.onclick = function(x) {<br />
        //store the variable so that we can actually use it within each function<br />
        var p = x;<br />
        return function() {<br />
          var w = window.open(p); //try and open up a new window with the url<br />
          if(!w) { //check to see if the window opened<br />
            //let the user know that a window didnt open<br />
            alert("A popup blocker seems to have blocked the window from opening");<br />
          }</p>
<p>          //return false to make sure the browser doesnt navigate away in the current window also<br />
          return false;<br />
        }<br />
      }(anchor.getAttribute("href")); //pass through the href for this anchor<br />
    }<br />
  }<br />
}</p>
<p>//make sure we only set everything up on load<br />
//after the DOM has been inited<br />
window.onload = externalLinks;<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Helen</title>
		<link>http://www.elanman.co.uk/2009/05/open-a-new-browser-window/comment-page-1/#comment-73</link>
		<dc:creator>Helen</dc:creator>
		<pubDate>Sun, 03 May 2009 09:42:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.elanman.co.uk/?p=808#comment-73</guid>
		<description>Excellent stuff my man!

I really don&#039;t like using the transitional doctype (though I&#039;m not anal about it like some people) But, having loads of links for my portfolio, I felt it necessary.

The only thing now, is that I have to work through converting the pages!</description>
		<content:encoded><![CDATA[<p>Excellent stuff my man!</p>
<p>I really don&#8217;t like using the transitional doctype (though I&#8217;m not anal about it like some people) But, having loads of links for my portfolio, I felt it necessary.</p>
<p>The only thing now, is that I have to work through converting the pages!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
