<?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"
	>
<channel>
	<title>Comments on: Dealing with unqualified HREF values</title>
	<atom:link href="http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<pubDate>Fri, 05 Dec 2008 00:04:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: brothercake</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-385442</link>
		<dc:creator>brothercake</dc:creator>
		<pubDate>Tue, 18 Sep 2007 01:16:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-385442</guid>
		<description>Oh, the &#60;base&#62; element, yeah I hadn't though of that.

Well that would similarly require feeding the function with a context location, and to do that it would need to start parsing location URIs as strings instead of relying on the location object; but doing that might also fix the &#60;iframe&#62; problem in IE, as well as allowing for processing of any context however created, not just window locations.

I'll give it some thought and post again in due course!</description>
		<content:encoded><![CDATA[<p>Oh, the &lt;base&gt; element, yeah I hadn&#8217;t though of that.</p>
<p>Well that would similarly require feeding the function with a context location, and to do that it would need to start parsing location URIs as strings instead of relying on the location object; but doing that might also fix the &lt;iframe&gt; problem in IE, as well as allowing for processing of any context however created, not just window locations.</p>
<p>I&#8217;ll give it some thought and post again in due course!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: nic</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-348895</link>
		<dc:creator>nic</dc:creator>
		<pubDate>Fri, 24 Aug 2007 17:43:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-348895</guid>
		<description>sorry, submitted too soon. 

With a &#60;base&#62; tag, the document.location may refer to one URL, but the base tag would override this -- for example a page on www.domain-one.com might have a base tag with an href of www.domain-two.com -- any relative links which appeared on the page, a browser would send to domain-two, but because you're looking at document.location, this script would still see it as domain-one.</description>
		<content:encoded><![CDATA[<p>sorry, submitted too soon. </p>
<p>With a &lt;base&gt; tag, the document.location may refer to one URL, but the base tag would override this &#8212; for example a page on <a href="http://www.domain-one.com" rel="nofollow">http://www.domain-one.com</a> might have a base tag with an href of <a href="http://www.domain-two.com" rel="nofollow">http://www.domain-two.com</a> &#8212; any relative links which appeared on the page, a browser would send to domain-two, but because you&#8217;re looking at document.location, this script would still see it as domain-one.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: nic</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-348891</link>
		<dc:creator>nic</dc:creator>
		<pubDate>Fri, 24 Aug 2007 17:39:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-348891</guid>
		<description>Actually I meant a &#60;base&#62; tag!</description>
		<content:encoded><![CDATA[<p>Actually I meant a &lt;base&gt; tag!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: brothercake</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-335086</link>
		<dc:creator>brothercake</dc:creator>
		<pubDate>Tue, 14 Aug 2007 07:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-335086</guid>
		<description>(Your tag was edited out - remember that HTML needs to be entities to show up as code.)

Anyway, assuming you meant an &#60;iframe&#62; - that's a very good question. I did originally have a context parameter that could accept an input document location object rather than using the main one:

&lt;code&gt;function qualifyHREF(href, context)  
{  
	if(typeof context == 'undefined')
	{
		var loc = document.location;  
	}
	else
	{
		loc = context;
	}
&lt;/code&gt;

And that could then be called like this:

&lt;code&gt;qualifyHREF('whatever.html', document.getElementById('myiframe').location);&lt;/code&gt;

But that failed in Internet Explorer. I'm not sure why (I never got as far as investigating) but I think it might be that  IE doesn't expose the location object of an iframe page in that straightforward way. It might be necessary to get the iframe reference through the document.frames collection, or perhaps you need to drill down into the iframe object to get its contentDocument, and then that will have a location object.</description>
		<content:encoded><![CDATA[<p>(Your tag was edited out - remember that HTML needs to be entities to show up as code.)</p>
<p>Anyway, assuming you meant an &lt;iframe&gt; - that&#8217;s a very good question. I did originally have a context parameter that could accept an input document location object rather than using the main one:</p>
<code>function qualifyHREF(href, context)  
{  
	if(typeof context == 'undefined')
	{
		var loc = document.location;  
	}
	else
	{
		loc = context;
	}
</code>
<p>And that could then be called like this:</p>
<code>qualifyHREF('whatever.html', document.getElementById('myiframe').location);</code>
<p>But that failed in Internet Explorer. I&#8217;m not sure why (I never got as far as investigating) but I think it might be that  IE doesn&#8217;t expose the location object of an iframe page in that straightforward way. It might be necessary to get the iframe reference through the document.frames collection, or perhaps you need to drill down into the iframe object to get its contentDocument, and then that will have a location object.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: nick</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-334666</link>
		<dc:creator>nick</dc:creator>
		<pubDate>Mon, 13 Aug 2007 10:15:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-334666</guid>
		<description>How do browsers (and this script) deal with a  tag? The full path may not necessarily use document.location, but some other location specified by the author.</description>
		<content:encoded><![CDATA[<p>How do browsers (and this script) deal with a  tag? The full path may not necessarily use document.location, but some other location specified by the author.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: brothercake</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331309</link>
		<dc:creator>brothercake</dc:creator>
		<pubDate>Fri, 10 Aug 2007 13:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331309</guid>
		<description>LOL, nice hack - never even occured to me :)</description>
		<content:encoded><![CDATA[<p>LOL, nice hack - never even occured to me :)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Clay</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331299</link>
		<dc:creator>Steve Clay</dc:creator>
		<pubDate>Fri, 10 Aug 2007 12:38:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331299</guid>
		<description>Considering the first half of the article, I thought you were gearing up to do this:
&lt;code&gt;
function qualifyHREF(href) {
  var div = document.body.appendChild(document.createElement('div'));
  div.innerHTML = '&#60;a href="' + href + '"&#62;&#60;/a&#62;';
  var ret = div.getElementsByTagName('a')[0].href;
  document.body.removeChild(div);
  return ret;
}
&lt;/code&gt;
:) Kind of a joke, but...</description>
		<content:encoded><![CDATA[<p>Considering the first half of the article, I thought you were gearing up to do this:<br />
<code>
function qualifyHREF(href) {
  var div = document.body.appendChild(document.createElement('div'));
  div.innerHTML = '&lt;a href="' + href + '"&gt;&lt;/a&gt;';
  var ret = div.getElementsByTagName('a')[0].href;
  document.body.removeChild(div);
  return ret;
}
</code><br />
:) Kind of a joke, but&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tyssen</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331159</link>
		<dc:creator>Tyssen</dc:creator>
		<pubDate>Fri, 10 Aug 2007 08:33:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331159</guid>
		<description>Sitepoint needs to update your article bio info, well the first part at least. ;)</description>
		<content:encoded><![CDATA[<p>Sitepoint needs to update your article bio info, well the first part at least. ;)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Yank</title>
		<link>http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331132</link>
		<dc:creator>Kevin Yank</dc:creator>
		<pubDate>Fri, 10 Aug 2007 06:38:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/#comment-331132</guid>
		<description>Also mentioned in Simply JavaScript, here's some further reading on the mess of retrieving attributes in IE: &lt;a href="http://tobielangel.com/2007/1/11/attribute-nightmare-in-ie" rel="nofollow"&gt;Attribute Nightmare In IE&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Also mentioned in Simply JavaScript, here&#8217;s some further reading on the mess of retrieving attributes in IE: <a href="http://tobielangel.com/2007/1/11/attribute-nightmare-in-ie" rel="nofollow">Attribute Nightmare In IE</a>.</p>]]></content:encoded>
	</item>
</channel>
</rss>
