Implementing setTimeout native method

browser-extension, internet-explorer, javascript, setinterval, settimeout

Solution

You could create an iframe and then access it's `window` object, get the fresh `setTimeout` definition and overwrite the one in your global namespace :

var f = document.createElement('iframe');
document.body.appendChild(f);
window.setTimeout = f.contentWindow.setTimeout;
document.body.removeChild(f);  

Although this works, it's probably not a good ideea for 2 scripts to start overwriting each other's variables. I suggest you let FB to take control over the `setTimeout` function and you use the fresh copy of it, but not to overwrite it again (you can store it in a local var, or in a global variable with another name).

Problem

I'm working on browser-extension in facebook, now my problem is that facebook override the setTimeout & setInterval native functions, and their implementation do not work on Internet Explorer. Is there a way to implement those functions?

Original source