<?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: Eval&#8217;ing with IE&#8217;s window.execScript</title>
	<atom:link href="http://ajaxian.com/archives/evaling-with-ies-windowexecscript/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: azendal</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-279706</link>
		<dc:creator>azendal</dc:creator>
		<pubDate>Thu, 04 Mar 2010 18:53:53 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-279706</guid>
		<description>There is another Solution, seems like the code that gets executed when using eval, checks if you are evaluating a function, so the trick is tell it its an object like this
var x = eval(&quot;({fn:function(){alert(54)}})&quot;)

now you can easily get x.fn() // 54

this was testes on ie7</description>
		<content:encoded><![CDATA[<p>There is another Solution, seems like the code that gets executed when using eval, checks if you are evaluating a function, so the trick is tell it its an object like this<br />
var x = eval(&#8220;({fn:function(){alert(54)}})&#8221;)</p>
<p>now you can easily get x.fn() // 54</p>
<p>this was testes on ie7</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: morrisj</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-268381</link>
		<dc:creator>morrisj</dc:creator>
		<pubDate>Fri, 24 Oct 2008 05:25:45 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-268381</guid>
		<description>execScript() is evil.

If the script has an error when it runs, then execScript() catches the exception, and it creates a *new* exception: &quot;Could not complete the operation due to error 80020101&quot;. You lose all information about the original error...

If you get 80020101 on a client&#039;s machine you have *no* information about the error - and it will be a bitch to diagnose (google 80020101 - lots of problems and incorrect answers). [PS: If you are reading this because you have got that error, then try replacing &quot;execScript(code);&quot; with &quot;(window.eval &#124;&#124; eval)(code, null);&quot; !] 

To see the error, try the following in the address bar IE6 (without a debugger installed - your clients don&#039;t have one!): javascript:execScript(&#039;syntaxerror;&#039;);

Calling eval(code, null); is the way to go for non-IE browsers, because the second parameter is the context and null means use global as the context.

Ryan Moore:
You had a link to &lt;a href=&quot;http://www.hedgerwow.com/360/bugs/eval.html&quot; rel=&quot;nofollow&quot;&gt;window.eval and eval&lt;/a&gt;
which says window.eval is evil - however the evilness is easily avoided by writing a global function which:
a) has *no* local variables (e.g. only does eval and returns) and 
b) is not declared inside another function (is *not* a closure - doesn&#039;t capture variables of the outer function/s.
c) calls window.eval or eval appropriately

Sebastian Werner:
(new Function(code))() is not the same. If the code contains any var statements at top level, then declared variables should end up in the scope of the function, not at global scope e.g. 
javascript:(new Function(&#039;var xxx=5&#039;))(); alert(window.xxx);
alerts undefined in IE6 (hmmmm - alerts 5 in FF) versus:
window.eval(&#039;var xxx=5&#039;); alert(window.xxx);
alerts 5.

lou:
try { window.execScript(code); } catch (e) {}
try { eval(code); } catch (e) {}
That will run the code twice on IE - not what you want at all.</description>
		<content:encoded><![CDATA[<p>execScript() is evil.</p>
<p>If the script has an error when it runs, then execScript() catches the exception, and it creates a *new* exception: &#8220;Could not complete the operation due to error 80020101&#8243;. You lose all information about the original error&#8230;</p>
<p>If you get 80020101 on a client&#8217;s machine you have *no* information about the error &#8211; and it will be a bitch to diagnose (google 80020101 &#8211; lots of problems and incorrect answers). [PS: If you are reading this because you have got that error, then try replacing "execScript(code);" with "(window.eval || eval)(code, null);" !] </p>
<p>To see the error, try the following in the address bar IE6 (without a debugger installed &#8211; your clients don&#8217;t have one!): javascript:execScript(&#8216;syntaxerror;&#8217;);</p>
<p>Calling eval(code, null); is the way to go for non-IE browsers, because the second parameter is the context and null means use global as the context.</p>
<p>Ryan Moore:<br />
You had a link to <a href="http://www.hedgerwow.com/360/bugs/eval.html" rel="nofollow">window.eval and eval</a><br />
which says window.eval is evil &#8211; however the evilness is easily avoided by writing a global function which:<br />
a) has *no* local variables (e.g. only does eval and returns) and<br />
b) is not declared inside another function (is *not* a closure &#8211; doesn&#8217;t capture variables of the outer function/s.<br />
c) calls window.eval or eval appropriately</p>
<p>Sebastian Werner:<br />
(new Function(code))() is not the same. If the code contains any var statements at top level, then declared variables should end up in the scope of the function, not at global scope e.g.<br />
javascript:(new Function(&#8216;var xxx=5&#8242;))(); alert(window.xxx);<br />
alerts undefined in IE6 (hmmmm &#8211; alerts 5 in FF) versus:<br />
window.eval(&#8216;var xxx=5&#8242;); alert(window.xxx);<br />
alerts 5.</p>
<p>lou:<br />
try { window.execScript(code); } catch (e) {}<br />
try { eval(code); } catch (e) {}<br />
That will run the code twice on IE &#8211; not what you want at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lou</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-257170</link>
		<dc:creator>lou</dc:creator>
		<pubDate>Mon, 15 Oct 2007 15:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-257170</guid>
		<description>Thank you, execScript was exactly what I was looking for.

How about:
try { window.execScript(code); } catch (e) {}
try { eval(code); } catch (e) {}</description>
		<content:encoded><![CDATA[<p>Thank you, execScript was exactly what I was looking for.</p>
<p>How about:<br />
try { window.execScript(code); } catch (e) {}<br />
try { eval(code); } catch (e) {}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wow powerleveling</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-250925</link>
		<dc:creator>wow powerleveling</dc:creator>
		<pubDate>Mon, 28 May 2007 17:52:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-250925</guid>
		<description>Thank u very much and u did a great job

i think it  iwould be better to use a textarea then apply the source formatting behind it.</description>
		<content:encoded><![CDATA[<p>Thank u very much and u did a great job</p>
<p>i think it  iwould be better to use a textarea then apply the source formatting behind it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Thuerigen</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248898</link>
		<dc:creator>Frank Thuerigen</dc:creator>
		<pubDate>Sat, 31 Mar 2007 16:14:47 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248898</guid>
		<description>Just to clarify since IÂ´ve been asked:
-
twobirds.js IS open source
twobirds_fw.js IS open source
twobirds_application.js IS NOT open source
-
The two open source parts fully allow on-demand-everything crossbrowser, application add nothing to that.
-
Frankie</description>
		<content:encoded><![CDATA[<p>Just to clarify since IÂ´ve been asked:<br />
-<br />
twobirds.js IS open source<br />
twobirds_fw.js IS open source<br />
twobirds_application.js IS NOT open source<br />
-<br />
The two open source parts fully allow on-demand-everything crossbrowser, application add nothing to that.<br />
-<br />
Frankie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Thuerigen</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248897</link>
		<dc:creator>Frank Thuerigen</dc:creator>
		<pubDate>Sat, 31 Mar 2007 16:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248897</guid>
		<description>correcting the above comment (sry):

tb.element.show( â€˜bodyDivâ€™ , â€˜applicationâ€™, â€˜index_bodyâ€™ );</description>
		<content:encoded><![CDATA[<p>correcting the above comment (sry):</p>
<p>tb.element.show( â€˜bodyDivâ€™ , â€˜applicationâ€™, â€˜index_bodyâ€™ );</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Thuerigen</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248894</link>
		<dc:creator>Frank Thuerigen</dc:creator>
		<pubDate>Sat, 31 Mar 2007 14:29:10 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248894</guid>
		<description>And one last comment: a dynamic web-object programmed with twobirds is getting displayed using only one statement, for the element above that is:
-
tb.element.show( â€˜toprightcontainerâ€™ , â€˜applicationâ€™, â€˜index_bodyâ€™ );
-
This lib then performs everything necessary to display said element. It also caches everything, so once loaded no server access is required to display the same element again, except for sheer data, which I usually convey in a JSON container.
-
Frankie</description>
		<content:encoded><![CDATA[<p>And one last comment: a dynamic web-object programmed with twobirds is getting displayed using only one statement, for the element above that is:<br />
-<br />
tb.element.show( â€˜toprightcontainerâ€™ , â€˜applicationâ€™, â€˜index_bodyâ€™ );<br />
-<br />
This lib then performs everything necessary to display said element. It also caches everything, so once loaded no server access is required to display the same element again, except for sheer data, which I usually convey in a JSON container.<br />
-<br />
Frankie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Thuerigen</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248893</link>
		<dc:creator>Frank Thuerigen</dc:creator>
		<pubDate>Sat, 31 Mar 2007 14:21:56 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248893</guid>
		<description>For those who didnÂ´t find the code snippet that self-explaining, it simply translates to this:
-
&quot;On object initialization, load the three files named from their module directories. Do this asynchronous (true). Once you are done, execute the display callback function (application.index_body.display).&quot;
-
The display function starts loading some more files required later (asynchronous by default) and in the meanwhile displays a login form topright.
-
This works no matter how many files are in the loading queue.
-
If anyone can come up with a solution that is simpler, IÂ´d like to see it. ;-)
-
Frankie
-
PS: to get to the chat on the prototype site you have to enter whatever user name and return, no pass required...</description>
		<content:encoded><![CDATA[<p>For those who didnÂ´t find the code snippet that self-explaining, it simply translates to this:<br />
-<br />
&#8220;On object initialization, load the three files named from their module directories. Do this asynchronous (true). Once you are done, execute the display callback function (application.index_body.display).&#8221;<br />
-<br />
The display function starts loading some more files required later (asynchronous by default) and in the meanwhile displays a login form topright.<br />
-<br />
This works no matter how many files are in the loading queue.<br />
-<br />
If anyone can come up with a solution that is simpler, IÂ´d like to see it. ;-)<br />
-<br />
Frankie<br />
-<br />
PS: to get to the chat on the prototype site you have to enter whatever user name and return, no pass required&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Thuerigen</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248892</link>
		<dc:creator>Frank Thuerigen</dc:creator>
		<pubDate>Sat, 31 Mar 2007 14:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248892</guid>
		<description>Additional comment:

The twobirds system documentation will be about 1 page for each &quot;core&quot; and &quot;framework&quot;. There is nothing more required to fully explain the system.

If you want to contact me, my eMail is frank dot thuerigen -at- phpbuero justAnotherDot de. Please add &quot;ajaxian&quot; to the topic line so I know where it comes from - I get a lot of spam in english language and IÂ´d like to see the comments, not find them after a year in the spam bin  ;-)

Have fun!</description>
		<content:encoded><![CDATA[<p>Additional comment:</p>
<p>The twobirds system documentation will be about 1 page for each &#8220;core&#8221; and &#8220;framework&#8221;. There is nothing more required to fully explain the system.</p>
<p>If you want to contact me, my eMail is frank dot thuerigen -at- phpbuero justAnotherDot de. Please add &#8220;ajaxian&#8221; to the topic line so I know where it comes from &#8211; I get a lot of spam in english language and IÂ´d like to see the comments, not find them after a year in the spam bin  ;-)</p>
<p>Have fun!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Thuerigen</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248891</link>
		<dc:creator>Frank Thuerigen</dc:creator>
		<pubDate>Sat, 31 Mar 2007 13:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248891</guid>
		<description>Not having read all of the comments above, the problem is solved for CSS, TEMPLATE and JS CODE files in the twoBirds lib (with framework addon lib). No eval() needed (!) and easy to debug...

Look at the following code snippet, it will explain everything:

application.index_body = {

 init: function (pDivId) {
  tb.element.require( 
   &quot;[ [ &#039;css&#039;, &#039;application&#039;, &#039;index_body&#039; ], &quot; +
   &quot; [ &#039;tpl&#039;, &#039;application&#039;, &#039;index_body&#039; ], &quot; +
   &quot; [ &#039;js&#039;, &#039;tb&#039;, &#039;effect.fadeTo&#039; ] ]&quot;,                   
   &#039;application.index_body.display( &quot;&#039; + pDivId + &#039;&quot; )&#039; ,
   true
   );
  },

 display: function (pDivId) {
  var myHtml = tb.loader.tplget(&#039;application&#039;,&#039;index_body&#039;);
  tb.div.replace( pDivId, myHtml );
  tb.element.require( 
   &quot;[ [ &#039;js&#039;, &#039;application&#039;, &#039;menu&#039; ], &quot; +
   &quot; [ &#039;css&#039;, &#039;application&#039;, &#039;menu&#039; ], &quot; +
   &quot; [ &#039;tpl&#039;, &#039;application&#039;, &#039;menu&#039; ], &quot; +
   &quot; [ &#039;js&#039;, &#039;application&#039;, &#039;user_greeting&#039; ], &quot; +
   &quot; [ &#039;css&#039;, &#039;application&#039;, &#039;user_greeting&#039; ], &quot; +
   &quot; [ &#039;tpl&#039;, &#039;application&#039;, &#039;user_greeting&#039; ], &quot; +
   &quot; [ &#039;js&#039;, &#039;application&#039;, &#039;submenu&#039; ], &quot; +
   &quot; [ &#039;css&#039;, &#039;application&#039;, &#039;submenu&#039; ], &quot; +
   &quot; [ &#039;tpl&#039;, &#039;application&#039;, &#039;submenu&#039; ], &quot; +
   &quot; [ &#039;js&#039;, &#039;application&#039;, &#039;window&#039; ], &quot; +
   &quot; [ &#039;css&#039;, &#039;application&#039;, &#039;window&#039; ], &quot; +
   &quot; [ &#039;tpl&#039;, &#039;application&#039;, &#039;window&#039; ] ]&quot; 
   );

  tb.element.show( &#039;toprightcontainer&#039; , &#039;application&#039;, &#039;user_login&#039; ); 
  }
  
 };

This is productive code. I was working on that special problem for more than 1 year, now it works on every browser thats halfway modern. This is only a fraction of the libs abilities. I can recursively load objects consisting of css,tpl and js object code files, it all works asynchronous and executes out-of-order. In my opinion this allows unlimited complexity while having managable code.

twoBirds V2.0 has just been declared stable, it works easily with other libs. And it is open source.

Im working on my HP now to make a download and documentation area (had no time for that so far), but the libs are pretty self-explaining just in case you want to rip the code from the prototype. The window management system is NOT OPEN SOURCE though. And it is a work in progress, permanent beta.

Cheers from Germany, Frankie.</description>
		<content:encoded><![CDATA[<p>Not having read all of the comments above, the problem is solved for CSS, TEMPLATE and JS CODE files in the twoBirds lib (with framework addon lib). No eval() needed (!) and easy to debug&#8230;</p>
<p>Look at the following code snippet, it will explain everything:</p>
<p>application.index_body = {</p>
<p> init: function (pDivId) {<br />
  tb.element.require(<br />
   &#8220;[ [ 'css', 'application', 'index_body' ], &#8221; +<br />
   &#8221; [ 'tpl', 'application', 'index_body' ], &#8221; +<br />
   &#8221; [ 'js', 'tb', 'effect.fadeTo' ] ]&#8221;,<br />
   &#8216;application.index_body.display( &#8220;&#8216; + pDivId + &#8216;&#8221; )&#8217; ,<br />
   true<br />
   );<br />
  },</p>
<p> display: function (pDivId) {<br />
  var myHtml = tb.loader.tplget(&#8216;application&#8217;,'index_body&#8217;);<br />
  tb.div.replace( pDivId, myHtml );<br />
  tb.element.require(<br />
   &#8220;[ [ 'js', 'application', 'menu' ], &#8221; +<br />
   &#8221; [ 'css', 'application', 'menu' ], &#8221; +<br />
   &#8221; [ 'tpl', 'application', 'menu' ], &#8221; +<br />
   &#8221; [ 'js', 'application', 'user_greeting' ], &#8221; +<br />
   &#8221; [ 'css', 'application', 'user_greeting' ], &#8221; +<br />
   &#8221; [ 'tpl', 'application', 'user_greeting' ], &#8221; +<br />
   &#8221; [ 'js', 'application', 'submenu' ], &#8221; +<br />
   &#8221; [ 'css', 'application', 'submenu' ], &#8221; +<br />
   &#8221; [ 'tpl', 'application', 'submenu' ], &#8221; +<br />
   &#8221; [ 'js', 'application', 'window' ], &#8221; +<br />
   &#8221; [ 'css', 'application', 'window' ], &#8221; +<br />
   &#8221; [ 'tpl', 'application', 'window' ] ]&#8221;<br />
   );</p>
<p>  tb.element.show( &#8216;toprightcontainer&#8217; , &#8216;application&#8217;, &#8216;user_login&#8217; );<br />
  }</p>
<p> };</p>
<p>This is productive code. I was working on that special problem for more than 1 year, now it works on every browser thats halfway modern. This is only a fraction of the libs abilities. I can recursively load objects consisting of css,tpl and js object code files, it all works asynchronous and executes out-of-order. In my opinion this allows unlimited complexity while having managable code.</p>
<p>twoBirds V2.0 has just been declared stable, it works easily with other libs. And it is open source.</p>
<p>Im working on my HP now to make a download and documentation area (had no time for that so far), but the libs are pretty self-explaining just in case you want to rip the code from the prototype. The window management system is NOT OPEN SOURCE though. And it is a work in progress, permanent beta.</p>
<p>Cheers from Germany, Frankie.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhiraj</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248010</link>
		<dc:creator>Abhiraj</dc:creator>
		<pubDate>Mon, 12 Mar 2007 05:33:14 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248010</guid>
		<description>Sorry Again ... I wish i could delete the previous comment. Anyways here is what i had to post.
a.html
----------------------
&lt;input type=&#039;button&#039; value=&#039;Test&#039; onclick=&#039;alert(test())&#039;&gt;
&lt;iframe src=&#039;b.html&#039;&gt;&lt;/iframe&gt;//HIDDEN IFRAME.

b.html
----------------------
&lt;script language=&#039;javascript&#039;&gt;
function loadTest()
{
window.parent.eval(&quot;function test(){return &#039;success&#039;;}&quot;)
}
&lt;/script&gt;
&lt;input type=&#039;button&#039; value=&#039;Load&#039; onclick=&#039;loadTest()&#039;&gt;</description>
		<content:encoded><![CDATA[<p>Sorry Again &#8230; I wish i could delete the previous comment. Anyways here is what i had to post.<br />
a.html<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&lt;input type=&#8217;button&#8217; value=&#8217;Test&#8217; onclick=&#8217;alert(test())&#8217;&gt;<br />
&lt;iframe src=&#8217;b.html&#8217;&gt;&lt;/iframe&gt;//HIDDEN IFRAME.</p>
<p>b.html<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&lt;script language=&#8217;javascript&#8217;&gt;<br />
function loadTest()<br />
{<br />
window.parent.eval(&#8220;function test(){return &#8216;success&#8217;;}&#8221;)<br />
}<br />
&lt;/script&gt;<br />
&lt;input type=&#8217;button&#8217; value=&#8217;Load&#8217; onclick=&#8217;loadTest()&#8217;&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhiraj</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248009</link>
		<dc:creator>Abhiraj</dc:creator>
		<pubDate>Mon, 12 Mar 2007 05:29:13 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248009</guid>
		<description>sorry HTML tags lost in the previous comments:
a.html
---------------------------
&lt;code&gt;

//HIDDEN IFRAME.
&lt;/code&gt;

b.html
---------------------------
&lt;code&gt;

function loadTest()
{
window.parent.eval(&quot;function test(){return &#039;success&#039;;}&quot;)
}


&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>sorry HTML tags lost in the previous comments:<br />
a.html<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
<code></p>
<p>//HIDDEN IFRAME.<br />
</code></p>
<p>b.html<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
<code></p>
<p>function loadTest()<br />
{<br />
window.parent.eval("function test(){return 'success';}")<br />
}</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhiraj</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-248008</link>
		<dc:creator>Abhiraj</dc:creator>
		<pubDate>Mon, 12 Mar 2007 05:26:14 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-248008</guid>
		<description>Guys here is a solution to run a script in global scope:
Found as a bug reported, but seems will help us. Works fine in IE and fire fox.
a.html:
-------------------------------

//Can make it an HIDDEN IFRAME.

b.html
-------------------------------

function loadTest()
{
window.parent.eval(&quot;function test(){return &#039;success&#039;;}&quot;)
}



After loading a.html, click on &quot;Test&quot; button it doesn&#039;t work, now click on Load in the iframe and then click on &quot;Test&quot;. Hurray it works :-). Tested on IE6 and FF2</description>
		<content:encoded><![CDATA[<p>Guys here is a solution to run a script in global scope:<br />
Found as a bug reported, but seems will help us. Works fine in IE and fire fox.<br />
a.html:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>//Can make it an HIDDEN IFRAME.</p>
<p>b.html<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>function loadTest()<br />
{<br />
window.parent.eval(&#8220;function test(){return &#8216;success&#8217;;}&#8221;)<br />
}</p>
<p>After loading a.html, click on &#8220;Test&#8221; button it doesn&#8217;t work, now click on Load in the iframe and then click on &#8220;Test&#8221;. Hurray it works :-). Tested on IE6 and FF2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: max</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-247775</link>
		<dc:creator>max</dc:creator>
		<pubDate>Mon, 05 Mar 2007 21:07:32 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-247775</guid>
		<description>execScript() is particularly useful when implementing Multiple Document Interfaces (MD).  The sample below describes this in detail using the prototype windows class.  

http://www.codeproject.com/Ajax/AjaxMDIWeb.asp

I&#039;ve noticed that the sample works like a charm in IE, but that it degrades in Firefox because of its exclusive use of execScript.  I&#039;ve tried replacing it with window.eval() and surprisingly, that works in IE as well; but not firefox.  eval.call() doesn&#039;t work either.  And this leads me to believe that in FF, I&#039;m not get a proper reference to the win object?

Tried everything to get this sample to work in FF, but have had no luck.  A real brick wall.  I&#039;d truly appreciate any ideas you might have.</description>
		<content:encoded><![CDATA[<p>execScript() is particularly useful when implementing Multiple Document Interfaces (MD).  The sample below describes this in detail using the prototype windows class.  </p>
<p><a href="http://www.codeproject.com/Ajax/AjaxMDIWeb.asp" rel="nofollow">http://www.codeproject.com/Ajax/AjaxMDIWeb.asp</a></p>
<p>I&#8217;ve noticed that the sample works like a charm in IE, but that it degrades in Firefox because of its exclusive use of execScript.  I&#8217;ve tried replacing it with window.eval() and surprisingly, that works in IE as well; but not firefox.  eval.call() doesn&#8217;t work either.  And this leads me to believe that in FF, I&#8217;m not get a proper reference to the win object?</p>
<p>Tried everything to get this sample to work in FF, but have had no luck.  A real brick wall.  I&#8217;d truly appreciate any ideas you might have.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johann Flori-HImpel</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-246851</link>
		<dc:creator>Johann Flori-HImpel</dc:creator>
		<pubDate>Fri, 02 Feb 2007 22:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-246851</guid>
		<description>Eval also works in Firefox and IE. 

But it seems that:      function outer(){ function inner(){};  }
is handled like:          function outer(){ var inner = inner(){};  }
but not as:                function outer(){ inner = inner(){};  }

The last way exposes inner to the world.

You can see this in the jsolait-library and you can test it with an example found in http://planet.openjsan.org/

function loadMyFuncModule() {
  // imagine this was loaded via XHR/etc
  var code = &#039;function myFunc() { alert(\&quot;myFunc\&quot;); }&#039;;
  return eval(code); // doesnâ€™t work in FF or IE
}
        
function runApp() {
  loadMyFuncModule(); // load extra code â€œon demandâ€
  myFunc(); // execute newly loaded code
}

myFunc ();  // produces an error

With a little change it works:

loadMyFuncModule = function() {
  // imagine this was loaded via XHR/etc
  var code = &#039;myFunc = function() { alert(\&quot;myFunc\&quot;); }&#039;;
  return eval(code); // d o e s   work in FF and IE
}
        
runApp = function() {
  loadMyFuncModule(); // load extra code â€œon demandâ€
  myFunc(); // execute newly loaded code
}

runApp()</description>
		<content:encoded><![CDATA[<p>Eval also works in Firefox and IE. </p>
<p>But it seems that:      function outer(){ function inner(){};  }<br />
is handled like:          function outer(){ var inner = inner(){};  }<br />
but not as:                function outer(){ inner = inner(){};  }</p>
<p>The last way exposes inner to the world.</p>
<p>You can see this in the jsolait-library and you can test it with an example found in <a href="http://planet.openjsan.org/" rel="nofollow">http://planet.openjsan.org/</a></p>
<p>function loadMyFuncModule() {<br />
  // imagine this was loaded via XHR/etc<br />
  var code = &#8216;function myFunc() { alert(\&#8221;myFunc\&#8221;); }&#8217;;<br />
  return eval(code); // doesnâ€™t work in FF or IE<br />
}</p>
<p>function runApp() {<br />
  loadMyFuncModule(); // load extra code â€œon demandâ€<br />
  myFunc(); // execute newly loaded code<br />
}</p>
<p>myFunc ();  // produces an error</p>
<p>With a little change it works:</p>
<p>loadMyFuncModule = function() {<br />
  // imagine this was loaded via XHR/etc<br />
  var code = &#8216;myFunc = function() { alert(\&#8221;myFunc\&#8221;); }&#8217;;<br />
  return eval(code); // d o e s   work in FF and IE<br />
}</p>
<p>runApp = function() {<br />
  loadMyFuncModule(); // load extra code â€œon demandâ€<br />
  myFunc(); // execute newly loaded code<br />
}</p>
<p>runApp()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave t</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-246807</link>
		<dc:creator>dave t</dc:creator>
		<pubDate>Fri, 02 Feb 2007 06:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-246807</guid>
		<description>Ryan - Don&#039;t quite understand what you are dealing with innerHTML.  Are you dealing with the fact that  tags don&#039;t get evaluated when included as part of innerHTML?</description>
		<content:encoded><![CDATA[<p>Ryan &#8211; Don&#8217;t quite understand what you are dealing with innerHTML.  Are you dealing with the fact that  tags don&#8217;t get evaluated when included as part of innerHTML?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Frueh</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-246806</link>
		<dc:creator>Pete Frueh</dc:creator>
		<pubDate>Fri, 02 Feb 2007 05:59:58 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-246806</guid>
		<description>Here&#039;s my &quot;Missing Image Hack&quot;:
http://www.ajaxprogrammer.com/?p=17

Any HTML &quot;module&quot; that gets pulled in via XHR can run its own JavaScript.  The script executes in the global namespace, but won&#039;t pollute it.

It&#039;s ugly, but it works.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s my &#8220;Missing Image Hack&#8221;:<br />
<a href="http://www.ajaxprogrammer.com/?p=17" rel="nofollow">http://www.ajaxprogrammer.com/?p=17</a></p>
<p>Any HTML &#8220;module&#8221; that gets pulled in via XHR can run its own JavaScript.  The script executes in the global namespace, but won&#8217;t pollute it.</p>
<p>It&#8217;s ugly, but it works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Min</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-246778</link>
		<dc:creator>Min</dc:creator>
		<pubDate>Thu, 01 Feb 2007 13:53:01 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-246778</guid>
		<description>I agree with Sebastian&#039;s comment about using pre-defined namespaces. I think it&#039;s just a bad practice to dynamically load functions into global scope. No matter how careful you are about colliding function names or making sure each page loads correct functions, it is still possible that you can override functions you need by mistake or calling another page&#039;s function.</description>
		<content:encoded><![CDATA[<p>I agree with Sebastian&#8217;s comment about using pre-defined namespaces. I think it&#8217;s just a bad practice to dynamically load functions into global scope. No matter how careful you are about colliding function names or making sure each page loads correct functions, it is still possible that you can override functions you need by mistake or calling another page&#8217;s function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Williams</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-246776</link>
		<dc:creator>Matthew Williams</dc:creator>
		<pubDate>Thu, 01 Feb 2007 13:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-246776</guid>
		<description>How would I implement this for JavaScript that I&#039;m placing in a DIV from an AJAX.Updater call?  I&#039;m returning a Dojo widget and it does not render.  However, viewing a page with the same code renders the widget correctly.  But I can&#039;t figure out how to get it to render after the AJAX.Updater call using Prototype.  Thanks!</description>
		<content:encoded><![CDATA[<p>How would I implement this for JavaScript that I&#8217;m placing in a DIV from an AJAX.Updater call?  I&#8217;m returning a Dojo widget and it does not render.  However, viewing a page with the same code renders the widget correctly.  But I can&#8217;t figure out how to get it to render after the AJAX.Updater call using Prototype.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://ajaxian.com/archives/evaling-with-ies-windowexecscript/comment-page-1#comment-246774</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 01 Feb 2007 12:32:48 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2074#comment-246774</guid>
		<description>jgarces, your function does not behave the same for all browsers. 

globalEval(foo);
bar(); // defined in the just eval&#039;d code

This will work in IE, but it will not work in other browsers, as the timeout will not be triggered until the current script block finishes.</description>
		<content:encoded><![CDATA[<p>jgarces, your function does not behave the same for all browsers. </p>
<p>globalEval(foo);<br />
bar(); // defined in the just eval&#8217;d code</p>
<p>This will work in IE, but it will not work in other browsers, as the timeout will not be triggered until the current script block finishes.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

