 <p>You are getting a cross domain error because some properties on the window (global) object are not accessible within the iframe, assuming you should be allowed to access the global variable you are trying to read (because its in the iframe itself), you can wrap the inner part of the loop in a try catch block, this way it will continue after getting an access denied. See code:</p> <pre><code>var listScopeVars = function(scope) { for (var prop in scope) { try{ if(scope[prop] &amp;&amp; typeof(scope[prop]) != "function") { console.log(prop + "=" + scope[prop]); } }catch(e){ console.log("Error: "+e.message); //or use console.error("Error: "+e.message); } } }; </code></pre>