<?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: Closures and executing JavaScript on page load</title>
	<atom:link href="http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Mon, 23 Nov 2009 01:39:24 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Solmaz</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-879365</link>
		<dc:creator>Solmaz</dc:creator>
		<pubDate>Tue, 17 Feb 2009 07:18:04 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-879365</guid>
		<description>so useful... thank you.</description>
		<content:encoded><![CDATA[<p>so useful&#8230; thank you.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: myxo</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-843281</link>
		<dc:creator>myxo</dc:creator>
		<pubDate>Wed, 03 Dec 2008 13:46:43 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-843281</guid>
		<description>THANKS! Saved my ass.</description>
		<content:encoded><![CDATA[<p>THANKS! Saved my ass.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: johnnyboyNiumata</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-798965</link>
		<dc:creator>johnnyboyNiumata</dc:creator>
		<pubDate>Tue, 23 Sep 2008 13:15:41 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-798965</guid>
		<description>I love this latest code works great.....

I use it to load flash movies in after the rest of the page in conjunction with Robert Nymans &lt;a href=&quot;http://www.robertnyman.com/2007/04/19/flashreplace-a-light-weight-javascript-to-insert-flash-movies-into-your-web-page&quot; rel=&quot;nofollow&quot;&gt;flash loading script&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>I love this latest code works great&#8230;..</p>
<p>I use it to load flash movies in after the rest of the page in conjunction with Robert Nymans <a href="http://www.robertnyman.com/2007/04/19/flashreplace-a-light-weight-javascript-to-insert-flash-movies-into-your-web-page" rel="nofollow">flash loading script</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-778104</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 11 Aug 2008 06:49:57 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-778104</guid>
		<description>ff</description>
		<content:encoded><![CDATA[<p>ff</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Sanford</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-749475</link>
		<dc:creator>Allen Sanford</dc:creator>
		<pubDate>Mon, 23 Jun 2008 14:39:50 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-749475</guid>
		<description>Just in case you ar wondering no this does not work in firefox 3</description>
		<content:encoded><![CDATA[<p>Just in case you ar wondering no this does not work in firefox 3</p>]]></content:encoded>
	</item>
	<item>
		<title>By: buduznat</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-747818</link>
		<dc:creator>buduznat</dc:creator>
		<pubDate>Thu, 19 Jun 2008 16:13:56 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-747818</guid>
		<description>thank you!  i was banging my head on a problem for days :)    great work!</description>
		<content:encoded><![CDATA[<p>thank you!  i was banging my head on a problem for days :)    great work!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kylir Horton</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-330108</link>
		<dc:creator>Kylir Horton</dc:creator>
		<pubDate>Thu, 09 Aug 2007 02:27:20 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-330108</guid>
		<description>Amazing. This is beautiful. I&#039;ve used this in many locations on a web application I&#039;m working on and it has worked flawlessly and solved many problems which would have otherwise broken the application. Thank you very much for your work!</description>
		<content:encoded><![CDATA[<p>Amazing. This is beautiful. I&#8217;ve used this in many locations on a web application I&#8217;m working on and it has worked flawlessly and solved many problems which would have otherwise broken the application. Thank you very much for your work!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Meteorbites</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-315266</link>
		<dc:creator>Meteorbites</dc:creator>
		<pubDate>Wed, 25 Jul 2007 10:04:14 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-315266</guid>
		<description>I&#039;m just wondering how it differs from using your sample below. (Figure 1.) on (Figure 2). Figure 2 achieved the same thing as Figure 1 with lesser code.

Figure 1

&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != &#039;function&#039;) {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(function() {
    document.body.style.backgroundColor = &#039;yellow&#039;;
})
addLoadEvent(function() {
    document.body.appendChild(document.createTextNode(&#039;Hungry&#039;));;
})
addLoadEvent(function() {
    document.body.appendChild(document.createTextNode(&#039; monkeys!&#039;));;
})
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;
window.onload=function()
{
  document.body.style.backgroundColor = &#039;yellow&#039;;
  document.body.appendChild(document.createTextNode(&#039;Hungry&#039;));
  document.body.appendChild(document.createTextNode(&#039; monkeys!&#039;));  
}
&lt;/code&gt;&lt;/pre&gt;


email: meteorbites@yahoo.com</description>
		<content:encoded><![CDATA[<p>I&#8217;m just wondering how it differs from using your sample below. (Figure 1.) on (Figure 2). Figure 2 achieved the same thing as Figure 1 with lesser code.</p>
<p>Figure 1</p>
<pre><code class="html">
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(function() {
    document.body.style.backgroundColor = 'yellow';
})
addLoadEvent(function() {
    document.body.appendChild(document.createTextNode('Hungry'));;
})
addLoadEvent(function() {
    document.body.appendChild(document.createTextNode(' monkeys!'));;
})
</code></pre>
<pre><code class="html">
window.onload=function()
{
  document.body.style.backgroundColor = 'yellow';
  document.body.appendChild(document.createTextNode('Hungry'));
  document.body.appendChild(document.createTextNode(' monkeys!'));  
}
</code></pre>
<p>email: <a href="mailto:meteorbites@yahoo.com">meteorbites@yahoo.com</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mike L</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-273422</link>
		<dc:creator>Mike L</dc:creator>
		<pubDate>Tue, 12 Jun 2007 20:49:42 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-273422</guid>
		<description>I just wanted to say thank you for providing this code and the explanation.

I have been fighting with some code on a page that I don&#039;t have the ability to insert into the &#039;body&#039; tag, and your code allowed me to overcome that problem.

Pasted it in, added the function name, and saved it.

It wourked perfectly, the very first time.

Thanks again.</description>
		<content:encoded><![CDATA[<p>I just wanted to say thank you for providing this code and the explanation.</p>
<p>I have been fighting with some code on a page that I don&#8217;t have the ability to insert into the &#8216;body&#8217; tag, and your code allowed me to overcome that problem.</p>
<p>Pasted it in, added the function name, and saved it.</p>
<p>It wourked perfectly, the very first time.</p>
<p>Thanks again.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie</title>
		<link>http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/comment-page-1/#comment-162925</link>
		<dc:creator>Charlie</dc:creator>
		<pubDate>Thu, 25 Jan 2007 18:48:06 +0000</pubDate>
		<guid isPermaLink="false">1860362158#comment-162925</guid>
		<description>Dear Sir

I am using Opera 8 on Windows XP.

I have embedded a Quick Time movie in the page. I have created a simple button that calls the movie to play:

object.Play();

When I press the reload button at the top of the Opera browser and try clicking on the play button again. The movie does not play. If I close Opera, and open it again and press play, it works. Infact I can press play several times aslong as I do not reload or refresh the browser.

In Opera 9, everything works fine, but I need to display this application on all versions of all browsers.

Do you know what might be causing the prolem. In the error console, I get:

name: TypeError
message: Statement on line 46: Type mismatch (usually a non-object value used where an object is required)

Please could you help me, I am tearing my hair out here!

Thanks in advance...

e-mail: cdesign@btinternet.com
mobile: 07881987197

Charlie</description>
		<content:encoded><![CDATA[<p>Dear Sir</p>
<p>I am using Opera 8 on Windows XP.</p>
<p>I have embedded a Quick Time movie in the page. I have created a simple button that calls the movie to play:</p>
<p>object.Play();</p>
<p>When I press the reload button at the top of the Opera browser and try clicking on the play button again. The movie does not play. If I close Opera, and open it again and press play, it works. Infact I can press play several times aslong as I do not reload or refresh the browser.</p>
<p>In Opera 9, everything works fine, but I need to display this application on all versions of all browsers.</p>
<p>Do you know what might be causing the prolem. In the error console, I get:</p>
<p>name: TypeError<br />
message: Statement on line 46: Type mismatch (usually a non-object value used where an object is required)</p>
<p>Please could you help me, I am tearing my hair out here!</p>
<p>Thanks in advance&#8230;</p>
<p>e-mail: <a href="mailto:cdesign@btinternet.com">cdesign@btinternet.com</a><br />
mobile: 07881987197</p>
<p>Charlie</p>]]></content:encoded>
	</item>
</channel>
</rss>
