Note that there are some explanatory texts on larger screens.

plurals
  1. PO'Date' is undefined in IE9 in javascript loaded by FacePile
    text
    copied!<p>I'm currently getting an error within Facebook's FacePile code, and I'm baffled by the cause.</p> <p>facepile.php loads a script which, among other things, has these lines (when pretty-printed):</p> <pre class="lang-js prettyprint-override"><code>... o = document.createElement('script'); o.src = l[n]; o.async = true; o.onload = h; o.onreadystatechange = function() { if (o.readyState in c) { h(); o.onreadystatechange = null; } }; d++; a.appendChild(o); ... </code></pre> <p>(a == document.body, d++ is irrelevant here)</p> <p>This code loads a script with src = <code>http://static.ak.fbcdn.net/rsrc.php/v1/yW/r/pmR8u_Z_9_0.js</code> or something equally cryptic (the filename changes occasionally).</p> <p>In that script, there are these lines at the very top (also when pretty-printed):</p> <pre class="lang-js prettyprint-override"><code> /*1331654128,176820664*/ if (window.CavalryLogger) { CavalryLogger.start_js(["\/8f24"]); } window.__DEV__ = window.__DEV__ || 0; if (!window.skipDomainLower &amp;&amp; document.domain.toLowerCase().match(/(^|\.)facebook\..*/)) document.domain = window.location.hostname.replace(/^.*(facebook\..*)$/i, '$1'); function bagofholding() { } function bagof(a) { return function() { return a; }; } if (!Date.now) Date.now = function now() { return new Date().getTime(); }; if (!Array.isArray) Array.isArray = function(a) { return Object.prototype.toString.call(a) == '[object Array]'; }; ... </code></pre> <p>And I'm getting an error which says "SCRIPT5009: 'Date' is undefined", right at the <code>if (!Date.now)</code> portion. Debugging near that point reveals that <code>Date</code>, <code>Array</code>, <code>Object</code>, <code>Function</code>, etc are all undefined.</p> <p>Er... how? <code>window</code> exists, as does <code>document</code> (though <code>document.body</code> is null) and a handful of others, but plenty of pre-defined objects aren't. Earlier versions of IE don't seem to have this problem, nor do any other browsers, but multiple machines running IE9 (including a clean VM) all have the same issue.</p> <p>I doubt I can do anything about it, but I'm <em>very</em> curious how this is happening / what the underlying problem is. Does anyone know, or can they point me to something that might help?</p> <p>-- edit:</p> <p>Prior to posting this question, I had found this site: <a href="http://www.guypo.com/technical/ies-premature-execution-problem/" rel="nofollow noreferrer">http://www.guypo.com/technical/ies-premature-execution-problem/</a></p> <p>While it seemed (and still does) like it might be the source of the problem, I can't replicate it under any smaller circumstances. All combinations I've tried still have Date, etc defined ; which isn't too surprising, as otherwise I'm sure others would be seeing many more problems with IE.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload