4

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?

gion_13
  • 41,171
  • 10
  • 96
  • 108
Ponpon32
  • 2,150
  • 2
  • 15
  • 26
  • What did they do to them? Why don't they work in IE - I can't believe they could write an app without them? – Bergi Oct 21 '12 at 12:14
  • i guess that they invoke them in some way, they do work for me on chrome and firefox and safari, only IE doesn't handle with there code. – Ponpon32 Oct 21 '12 at 12:17
  • If it's a browser extension, you could try to catch the methods before the Facebook script loads. eg `var myTimeout = setTimeout ;` – ColBeseder Oct 21 '12 at 12:30

1 Answers1

7

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).

gion_13
  • 41,171
  • 10
  • 96
  • 108
  • IE9 Throw access denied when i'm trying to access contentWindow property, using contents() in jquery return the document and not the window object. – Ponpon32 Oct 21 '12 at 12:57