<?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: Loading javascript: execScript and testing</title>
	<atom:link href="http://caih.org/open-source-software/loading-javascript-execscript-and-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://caih.org/open-source-software/loading-javascript-execscript-and-testing/</link>
	<description>Movies, life and python</description>
	<lastBuildDate>Wed, 04 Jan 2012 19:46:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: César Izurieta</title>
		<link>http://caih.org/open-source-software/loading-javascript-execscript-and-testing/comment-page-1/#comment-86</link>
		<dc:creator>César Izurieta</dc:creator>
		<pubDate>Tue, 30 Nov 2010 20:29:01 +0000</pubDate>
		<guid isPermaLink="false">http://caih.org/?p=113#comment-86</guid>
		<description>Hi Andrew,

There are several ways that other sites mention to have this working correctly, for example:

&lt;code lang=&quot;javascript&quot;&gt;
window.eval.call(window, contents);
&lt;/code&gt;

For a script to run correctly in eval the way it would run if loaded through an script tag these things have to be set:

&lt;blockquote&gt;Global Object = Activation Object = Variable Object = window&lt;/blockquote&gt;

IIRC: This means that if in the eval&#039;d code there&#039;s a variable assignment then it is assigned to the Activation Object. If &quot;this&quot; is used is assigned to the Variable Object. The Global Object that is always &quot;window&quot;.

I haven&#039;t checked this extensively, but different browsers set this objects to different values. Using only window.eval(contents) just forces the Variable Object to be set to window but not the Activation Object that might not be what we expect. Hence the use of &quot;with(window)&quot; is needed to set the Activation Object explicitly and is the only cross-browser solution I have tested personally. When eval&#039;ing, there&#039;s also a different Execution Context than when we include code with an script tag. But that is not possible to change using javascript and might, in some cases, present a problem to eval&#039;d scripts.

There is more information in this site: &lt;a href=&quot;http://bclary.com/2004/11/07/#a-10&quot; rel=&quot;nofollow&quot;&gt;http://bclary.com/2004/11/07/#a-10&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi Andrew,</p>
<p>There are several ways that other sites mention to have this working correctly, for example:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">window.<span style="color: #000066; font-weight: bold;">eval</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> contents<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>For a script to run correctly in eval the way it would run if loaded through an script tag these things have to be set:</p>
<blockquote><p>Global Object = Activation Object = Variable Object = window</p></blockquote>
<p>IIRC: This means that if in the eval&#8217;d code there&#8217;s a variable assignment then it is assigned to the Activation Object. If &#8220;this&#8221; is used is assigned to the Variable Object. The Global Object that is always &#8220;window&#8221;.</p>
<p>I haven&#8217;t checked this extensively, but different browsers set this objects to different values. Using only window.eval(contents) just forces the Variable Object to be set to window but not the Activation Object that might not be what we expect. Hence the use of &#8220;with(window)&#8221; is needed to set the Activation Object explicitly and is the only cross-browser solution I have tested personally. When eval&#8217;ing, there&#8217;s also a different Execution Context than when we include code with an script tag. But that is not possible to change using javascript and might, in some cases, present a problem to eval&#8217;d scripts.</p>
<p>There is more information in this site: <a href="http://bclary.com/2004/11/07/#a-10" rel="nofollow">http://bclary.com/2004/11/07/#a-10</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Hedges</title>
		<link>http://caih.org/open-source-software/loading-javascript-execscript-and-testing/comment-page-1/#comment-85</link>
		<dc:creator>Andrew Hedges</dc:creator>
		<pubDate>Tue, 30 Nov 2010 18:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://caih.org/?p=113#comment-85</guid>
		<description>Hi César,

I&#039;m curious what difference it makes to enclose window.eval() in the with statement since you access window.eval explicitly?

Thanks,
-Andrew</description>
		<content:encoded><![CDATA[<p>Hi César,</p>
<p>I&#8217;m curious what difference it makes to enclose window.eval() in the with statement since you access window.eval explicitly?</p>
<p>Thanks,<br />
-Andrew</p>
]]></content:encoded>
	</item>
</channel>
</rss>

