Twitter this

Powered by MariaDB Powered by nginx ...

IE and setTimeout issues

There's -again- something up with the implementation of JS script under IE, this time the setTimeout function. I see this coming back a lot on the mailing lists, people having problems using this function. I had to figure out the hard way until I came across Andrea Giammarchi's blog . From the information there I have the following at the top of every javascript page that needs this, here's what you put there:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  // IE fix, the following don't work in IE6 or IE7
   // See: http://webreflection.blogspot.com/2007/06/simple-settimeout-setinterval-extra.html
   // trackIntervalId = window.setInterval(function(){ loadMarker(trackeddev)},35000);
   // IE is such a bitch, this is to fix this: it wraps the function() so the arguments work
   // ONLY for IE

   /*@cc_on
   (function(f){
      window.setTimeout = f(window.setTimeout);
      window.setInterval = f(window.setInterval);
   })(function(f){
      return function(c,t){
         var a = Array.prototype.slice.call(arguments,2);
         if(typeof c != "function")
            c = new Function(c);
         return f(function(){
            c.apply(this, a)
         }, t)
      }
   });
   @*/

Hope this helps someone Googling this. Tx Andrea! A little Gem.

Comments are closed.

recruitment
recruitment
recruitment
recruitment