<?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: Getting a fully qualified URL</title>
	<atom:link href="http://james.padolsey.com/javascript/getting-a-fully-qualified-url/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:03:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-22551</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 19 Oct 2009 20:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-22551</guid>
		<description>@Kyle, thanks for the &quot;http://&quot; tip!

@Zach, funnily enough, that StackOverflow thread you just linked to was started by me (&quot;J-P&quot;)!</description>
		<content:encoded><![CDATA[<p>@Kyle, thanks for the &#8220;http://&#8221; tip!</p>
<p>@Zach, funnily enough, that StackOverflow thread you just linked to was started by me (&#8220;J-P&#8221;)!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zach Leatherman</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-22550</link>
		<dc:creator>Zach Leatherman</dc:creator>
		<pubDate>Mon, 19 Oct 2009 20:22:50 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-22550</guid>
		<description>Actually, a co-worker pointed out to me that the removeAttribute will not work properly either.  I found a silver-bullet approach using innerHTML over at http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue</description>
		<content:encoded><![CDATA[<p>Actually, a co-worker pointed out to me that the removeAttribute will not work properly either.  I found a silver-bullet approach using innerHTML over at <a href="http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue">http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zach Leatherman</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-22373</link>
		<dc:creator>Zach Leatherman</dc:creator>
		<pubDate>Fri, 16 Oct 2009 19:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-22373</guid>
		<description>Instead of
img.src = null;

This should work without making a request:
img.removeAttribute(&#039;src&#039;);

I would strongly encourage you to amend the article with this information, I was seeing serious issues with corrupted server-side models because of this extra &quot;null&quot; request, which would resolve to something like:
http://james.padolsey.com/javascript/null

Thanks,
Zach</description>
		<content:encoded><![CDATA[<p>Instead of<br />
img.src = null;</p>
<p>This should work without making a request:<br />
img.removeAttribute(&#8216;src&#8217;);</p>
<p>I would strongly encourage you to amend the article with this information, I was seeing serious issues with corrupted server-side models because of this extra &#8220;null&#8221; request, which would resolve to something like:<br />
<a href="http://james.padolsey.com/javascript/null">http://james.padolsey.com/javascript/null</a></p>
<p>Thanks,<br />
Zach</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Simpson</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-11330</link>
		<dc:creator>Kyle Simpson</dc:creator>
		<pubDate>Thu, 07 May 2009 15:15:37 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-11330</guid>
		<description>I just tried this in IE7.

Results: a request is made when you set img.src, but then it looks like it&#039;s canceled when you set src=null. So, technically, a request is fired off, but the page isn&#039;t suffering from the waiting for the response. 

However, I watched the server logs, and the server doesn&#039;t even receive the initial request, but it does receive the request for &quot;null&quot;, which of course (usually) will return a 404. So that kind of defeats the purpose. Trading one request for another isn&#039;t that helpful.

However, if you set img.src = &quot;http://&quot;, then it makes a dead request (no server load taken up), and should have little to no overhead in the browser processing/waiting (since this is javascript and asynch/non-blocking). 

The bad part is the server does still receive the initial script url request (in the logs), but again, IE7 has already abandoned the request by that point so the browser doesn&#039;t pay the penalty to process the response.

-------------

Also, I tried the a.href stuff, and that doesn&#039;t work when inserted by javascript, at least not in IE7. It just returns the same src you set to it. I even tried inserting the link into the body of the page, still no go.</description>
		<content:encoded><![CDATA[<p>I just tried this in IE7.</p>
<p>Results: a request is made when you set img.src, but then it looks like it&#8217;s canceled when you set src=null. So, technically, a request is fired off, but the page isn&#8217;t suffering from the waiting for the response. </p>
<p>However, I watched the server logs, and the server doesn&#8217;t even receive the initial request, but it does receive the request for &#8220;null&#8221;, which of course (usually) will return a 404. So that kind of defeats the purpose. Trading one request for another isn&#8217;t that helpful.</p>
<p>However, if you set img.src = &#8220;http://&#8221;, then it makes a dead request (no server load taken up), and should have little to no overhead in the browser processing/waiting (since this is javascript and asynch/non-blocking). </p>
<p>The bad part is the server does still receive the initial script url request (in the logs), but again, IE7 has already abandoned the request by that point so the browser doesn&#8217;t pay the penalty to process the response.</p>
<p>&#8212;&#8212;&#8212;&#8212;-</p>
<p>Also, I tried the a.href stuff, and that doesn&#8217;t work when inserted by javascript, at least not in IE7. It just returns the same src you set to it. I even tried inserting the link into the body of the page, still no go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-3432</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 22 Jan 2009 21:33:05 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-3432</guid>
		<description>Technically, a server request is made but since the &#039;src&#039; is set to null it just ends up being a request to the same page which means the overhead is non existent (I&#039;m not totally sure about this though). It might be worth introducing a compromise:

&lt;pre lang=&quot;javascript&quot;&gt;
function qualifyURL(url) {
    var a = document.createElement(&#039;a&#039;);
    a.href = url;
    if (/^http:\/\//.test(url)) {
        // IE7, FF, Op, Sf
        return a.href;
    } else {
        // IE6
        var img = document.createElement(&#039;img&#039;);
        img.src = url;
        return img.src;
    }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Technically, a server request is made but since the &#8216;src&#8217; is set to null it just ends up being a request to the same page which means the overhead is non existent (I&#8217;m not totally sure about this though). It might be worth introducing a compromise:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">function</span> qualifyURL<span class="br0">&#40;</span>url<span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="kw2">var</span> a <span class="sy0">=</span> document.<span class="me1">createElement</span><span class="br0">&#40;</span><span class="st0">'a'</span><span class="br0">&#41;</span><span class="sy0">;</span>
    a.<span class="me1">href</span> <span class="sy0">=</span> url<span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="co2">/^http:\/\//</span>.<span class="me1">test</span><span class="br0">&#40;</span>url<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="co1">// IE7, FF, Op, Sf</span>
        <span class="kw1">return</span> a.<span class="me1">href</span><span class="sy0">;</span>
    <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span>
        <span class="co1">// IE6</span>
        <span class="kw2">var</span> img <span class="sy0">=</span> document.<span class="me1">createElement</span><span class="br0">&#40;</span><span class="st0">'img'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        img.<span class="me1">src</span> <span class="sy0">=</span> url<span class="sy0">;</span>
        <span class="kw1">return</span> img.<span class="me1">src</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Milburn</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-3426</link>
		<dc:creator>Thomas Milburn</dc:creator>
		<pubDate>Thu, 22 Jan 2009 19:15:36 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-3426</guid>
		<description>It might not be completely your own but I like your modification and its a neat hack! Could you explain how your modification actually works. When would javascript normally make the server request. I would of thought it makes the server request when the image&#039;s &lt;code&gt;src&lt;/code&gt; is first set.</description>
		<content:encoded><![CDATA[<p>It might not be completely your own but I like your modification and its a neat hack! Could you explain how your modification actually works. When would javascript normally make the server request. I would of thought it makes the server request when the image&#8217;s <code>src</code> is first set.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-3415</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 22 Jan 2009 08:21:14 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-3415</guid>
		<description>Thanks all!

Yep, Thomas, you&#039;re correct, although I made my own little modification which prevents any server requests from being made. I suppose I shouldn&#039;t have called it &quot;&lt;strong&gt;my&lt;/strong&gt; magical method&quot;; I guess I&#039;m just a fan of alliteration! ;)</description>
		<content:encoded><![CDATA[<p>Thanks all!</p>
<p>Yep, Thomas, you&#8217;re correct, although I made my own little modification which prevents any server requests from being made. I suppose I shouldn&#8217;t have called it &#8220;<strong>my</strong> magical method&#8221;; I guess I&#8217;m just a fan of alliteration! <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Milburn</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-3414</link>
		<dc:creator>Thomas Milburn</dc:creator>
		<pubDate>Thu, 22 Jan 2009 08:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-3414</guid>
		<description>I presume James got the idea from &lt;a href=&quot;http://www.sitepoint.com/blogs/2007/10/17/dealing-with-unqualified-href-values-part-2/#comment-415704&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>I presume James got the idea from <a href="http://www.sitepoint.com/blogs/2007/10/17/dealing-with-unqualified-href-values-part-2/#comment-415704">here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brenelz</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-3405</link>
		<dc:creator>Brenelz</dc:creator>
		<pubDate>Wed, 21 Jan 2009 23:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-3405</guid>
		<description>Wow... neat trick James!

How did you find this one out?</description>
		<content:encoded><![CDATA[<p>Wow&#8230; neat trick James!</p>
<p>How did you find this one out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph McCann</title>
		<link>http://james.padolsey.com/javascript/getting-a-fully-qualified-url/comment-page-1/#comment-3404</link>
		<dc:creator>Joseph McCann</dc:creator>
		<pubDate>Wed, 21 Jan 2009 23:06:50 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=446#comment-3404</guid>
		<description>Very interesting...well done James.</description>
		<content:encoded><![CDATA[<p>Very interesting&#8230;well done James.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

