<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Javascript on vnykmshr</title><link>https://blog.vnykmshr.com/writing/tags/javascript/</link><description>Recent content in Javascript on vnykmshr</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 13 Nov 2011 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.vnykmshr.com/writing/tags/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title>The catch that never fired</title><link>https://blog.vnykmshr.com/writing/the-catch-that-never-fired/</link><pubDate>Sun, 13 Nov 2011 00:00:00 +0000</pubDate><guid>https://blog.vnykmshr.com/writing/the-catch-that-never-fired/</guid><description>&lt;p&gt;The page loads the same in every browser. The bug shows up in one of them, and never where I&amp;rsquo;m looking.&lt;/p&gt;
&lt;p&gt;An iframe on the page needs to know where its parent lives &amp;ndash; the URL in the top window. Different origin, so the same-origin policy is in play and the browser is allowed to refuse. I expect it to refuse. I wrote the code expecting it:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;try {
 var url = window.top.location.href;
 useIt(url);
} catch (e) {
 fallBack();
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In Firefox this does exactly what I planned. Reaching across origins for &lt;code&gt;location.href&lt;/code&gt; throws &amp;ndash; &lt;code&gt;Permission denied to get property Location.href&lt;/code&gt; &amp;ndash; the catch fires, &lt;code&gt;fallBack()&lt;/code&gt; runs, the page copes. IE throws too. The spec, as I read it, says it should.&lt;/p&gt;</description></item></channel></rss>