<?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"
	>
<channel>
	<title>Comments on: setInterval() Scope problem &#038; solutions for Firefox and Internet Explorer 6</title>
	<atom:link href="http://alexle.net/archives/169/feed" rel="self" type="application/rss+xml" />
	<link>http://alexle.net/archives/169</link>
	<description>Personal View</description>
	<pubDate>Thu, 09 Sep 2010 15:01:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Problemas de Ã¡mbito al definir un setInterval dentro de un objeto. &#171; ALeX sabe&#8230;</title>
		<link>http://alexle.net/archives/169#comment-298108</link>
		<dc:creator>Problemas de Ã¡mbito al definir un setInterval dentro de un objeto. &#171; ALeX sabe&#8230;</dc:creator>
		<pubDate>Mon, 19 Jul 2010 23:57:15 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-298108</guid>
		<description>[...] http://alexle.net/archives/169 [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://alexle.net/archives/169" rel="nofollow">http://alexle.net/archives/169</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: js setTimeout</title>
		<link>http://alexle.net/archives/169#comment-291478</link>
		<dc:creator>js setTimeout</dc:creator>
		<pubDate>Thu, 13 May 2010 13:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-291478</guid>
		<description>You could build your own bind method.

Function.prototype.bind = function(obj) {	
    var _method = this;
    return function() {
        return _method.apply(obj, arguments);
    };    
} 

setTimeout(this.method.bind(this),delay);</description>
		<content:encoded><![CDATA[<p>You could build your own bind method.</p>
<p>Function.prototype.bind = function(obj) {<br />
    var _method = this;<br />
    return function() {<br />
        return _method.apply(obj, arguments);<br />
    };<br />
} </p>
<p>setTimeout(this.method.bind(this),delay);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zhaabbaa</title>
		<link>http://alexle.net/archives/169#comment-240749</link>
		<dc:creator>zhaabbaa</dc:creator>
		<pubDate>Wed, 07 Jan 2009 07:52:49 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-240749</guid>
		<description>in prototype you can make it using bind
curTimeout = setTimeout( function(){ this.DoSomething( ); }.bind(this), this.nTimeout );

http://alternateidea.com/blog/articles/2007/7/18/javascript-scope-and-binding</description>
		<content:encoded><![CDATA[<p>in prototype you can make it using bind<br />
curTimeout = setTimeout( function(){ this.DoSomething( ); }.bind(this), this.nTimeout );</p>
<p><a href="http://alternateidea.com/blog/articles/2007/7/18/javascript-scope-and-binding" rel="nofollow">http://alternateidea.com/blog/articles/2007/7/18/javascript-scope-and-binding</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: codeplay</title>
		<link>http://alexle.net/archives/169#comment-238922</link>
		<dc:creator>codeplay</dc:creator>
		<pubDate>Fri, 26 Dec 2008 14:41:34 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-238922</guid>
		<description>It seems there is a uniform way to resolve this problem for various browsers (at least on FF, Safari, Chrome &#38; IE), call in the form of:

window.setInterval(function() { this.funcToBeCalled.apply(this); }, interval);
window.setTimeout(function() { this.funcToBeCalled.apply(this); }, t);
or
window.setInterval(function() { obj.funcToBeCalled.apply(obj); }, interval);
window.setTimeout(function() { obj.funcToBeCalled.apply(obj); }, t);

let me know if i am wrong, thanks! : yalpedoc AT gmail DOT com</description>
		<content:encoded><![CDATA[<p>It seems there is a uniform way to resolve this problem for various browsers (at least on FF, Safari, Chrome &amp; IE), call in the form of:</p>
<p>window.setInterval(function() { this.funcToBeCalled.apply(this); }, interval);<br />
window.setTimeout(function() { this.funcToBeCalled.apply(this); }, t);<br />
or<br />
window.setInterval(function() { obj.funcToBeCalled.apply(obj); }, interval);<br />
window.setTimeout(function() { obj.funcToBeCalled.apply(obj); }, t);</p>
<p>let me know if i am wrong, thanks! : yalpedoc AT gmail DOT com</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Reintzsch</title>
		<link>http://alexle.net/archives/169#comment-229136</link>
		<dc:creator>Alexander Reintzsch</dc:creator>
		<pubDate>Thu, 13 Nov 2008 12:56:45 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-229136</guid>
		<description>function TimeTicker()
{
  this.countdown = 0;
  if( document.all ){
    if (typeof globalScope != "object")
      globalScope = {currentId:0,getRandId:function(){return this.currentId++;}};
    globalScope[ this.uniqueId = globalScope.getRandId() ] = this;
    setInterval( 'globalScope["' + this.uniqueId + '"]["updateTime"]();', 999 );
  } else {
    this.timer = setInterval ( function( that ) { that.updateTime(); }, 999, this );
  }
}
TimeTicker.prototype.updateTime = function()
{
  window.status = this.uniqueId + " : " + this.countdown++;
}</description>
		<content:encoded><![CDATA[<p>function TimeTicker()<br />
{<br />
  this.countdown = 0;<br />
  if( document.all ){<br />
    if (typeof globalScope != &#8220;object&#8221;)<br />
      globalScope = {currentId:0,getRandId:function(){return this.currentId++;}};<br />
    globalScope[ this.uniqueId = globalScope.getRandId() ] = this;<br />
    setInterval( &#8216;globalScope[&#8221;&#8216; + this.uniqueId + &#8216;&#8221;][&#8221;updateTime&#8221;]();&#8217;, 999 );<br />
  } else {<br />
    this.timer = setInterval ( function( that ) { that.updateTime(); }, 999, this );<br />
  }<br />
}<br />
TimeTicker.prototype.updateTime = function()<br />
{<br />
  window.status = this.uniqueId + &#8221; : &#8221; + this.countdown++;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Reintzsch</title>
		<link>http://alexle.net/archives/169#comment-229133</link>
		<dc:creator>Alexander Reintzsch</dc:creator>
		<pubDate>Thu, 13 Nov 2008 12:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-229133</guid>
		<description>Sorry for posting twice,
but actually you don't need the ieIntervalHandler - method anymore.
use

setInterval( 'globalScope["' + this.uniqueId + '"]["updateTime"]();', 999 );

instead.

The example from above w/o comments.

var globalScope = {currentId:0,getRandomId:function(){return this.currentId++;}};

function TimeTicker()
{
  this.uniqueId = globalScope.getRandomId();
  this.countdown = 0;
  if( document.all ){
    globalScope[ this.uniqueId ] = this;
    setInterval( 'globalScope["' + this.uniqueId + '"]["updateTime"]();', 999 );
  } else {
    this.timer = setInterval ( function( that ) { that.updateTime(); }, 999, this );
  }
}
TimeTicker.prototype.updateTime = function()
{
  window.status = this.uniqueId + " : " + this.countdown++;
}</description>
		<content:encoded><![CDATA[<p>Sorry for posting twice,<br />
but actually you don&#8217;t need the ieIntervalHandler - method anymore.<br />
use</p>
<p>setInterval( &#8216;globalScope[&#8221;&#8216; + this.uniqueId + &#8216;&#8221;][&#8221;updateTime&#8221;]();&#8217;, 999 );</p>
<p>instead.</p>
<p>The example from above w/o comments.</p>
<p>var globalScope = {currentId:0,getRandomId:function(){return this.currentId++;}};</p>
<p>function TimeTicker()<br />
{<br />
  this.uniqueId = globalScope.getRandomId();<br />
  this.countdown = 0;<br />
  if( document.all ){<br />
    globalScope[ this.uniqueId ] = this;<br />
    setInterval( &#8216;globalScope[&#8221;&#8216; + this.uniqueId + &#8216;&#8221;][&#8221;updateTime&#8221;]();&#8217;, 999 );<br />
  } else {<br />
    this.timer = setInterval ( function( that ) { that.updateTime(); }, 999, this );<br />
  }<br />
}<br />
TimeTicker.prototype.updateTime = function()<br />
{<br />
  window.status = this.uniqueId + &#8221; : &#8221; + this.countdown++;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://alexle.net/archives/169#comment-225820</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 29 Oct 2008 18:51:26 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-225820</guid>
		<description>Thanks for all this info!  This helped me a lot, but I am still having problems.  How does clearInterval fit into all this.  Using Tim's code about javascript closures, I was able to get the setInterval working, but it would not end!  I would call clearInterval(this.timer) (this.timer being the return from setInterval, of course) from a different function, and it would not work.  How can you hook the timer variable into the scope so that it will cause the interval to stop running once it is cleared?</description>
		<content:encoded><![CDATA[<p>Thanks for all this info!  This helped me a lot, but I am still having problems.  How does clearInterval fit into all this.  Using Tim&#8217;s code about javascript closures, I was able to get the setInterval working, but it would not end!  I would call clearInterval(this.timer) (this.timer being the return from setInterval, of course) from a different function, and it would not work.  How can you hook the timer variable into the scope so that it will cause the interval to stop running once it is cleared?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vik</title>
		<link>http://alexle.net/archives/169#comment-197995</link>
		<dc:creator>Vik</dc:creator>
		<pubDate>Thu, 14 Aug 2008 03:35:08 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-197995</guid>
		<description>Thank you very much - my initial solution to the problem was a global array of objects - but using closure is much cleaner =)</description>
		<content:encoded><![CDATA[<p>Thank you very much - my initial solution to the problem was a global array of objects - but using closure is much cleaner =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: setInterval DIV bewegen IE Problem - jswelt - Forum (Javascript, PHP, MySQL, AJAX, Webdesign)</title>
		<link>http://alexle.net/archives/169#comment-169951</link>
		<dc:creator>setInterval DIV bewegen IE Problem - jswelt - Forum (Javascript, PHP, MySQL, AJAX, Webdesign)</dc:creator>
		<pubDate>Mon, 16 Jun 2008 18:04:57 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-169951</guid>
		<description>[...] -    Heute, 20:04         Tach,  Google-Suchstring &#34;ie setinterval problem&#34;, Platz 1:  Alex Le’s Blog » Blog Archive » setInterval() Scope problem &#38; solutions for Firefox and Internet...     Gruß, [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] -    Heute, 20:04         Tach,  Google-Suchstring &quot;ie setinterval problem&quot;, Platz 1:  Alex Le’s Blog » Blog Archive » setInterval() Scope problem &amp; solutions for Firefox and Internet&#8230;     Gruß, [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sepehr Lajevardi</title>
		<link>http://alexle.net/archives/169#comment-164171</link>
		<dc:creator>Sepehr Lajevardi</dc:creator>
		<pubDate>Tue, 03 Jun 2008 21:07:38 +0000</pubDate>
		<guid isPermaLink="false">http://alexle.net/archives/169#comment-164171</guid>
		<description>Many thanks Alex. 
I was absolutely disappointed about IE.</description>
		<content:encoded><![CDATA[<p>Many thanks Alex.<br />
I was absolutely disappointed about IE.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.226 seconds -->
