var MyFunc = MyObject.MySub.MyMethod
So they could just call MyFunc() instead. This "proxy" or "shorthand" works great in IE, but fails in Firefox/Safari and sometimes even crashes, saying it's an "illegal operation".
Two questions:
1) Is there a technical name for creating a simplified "pointer" to an existing function, so I can research this issue more easily, and.
2) Anybody got a clue as to why Firefox and Safari Crash, but IE accepts this and works fine? Is there a better way to do this?
Code sample follows:
Javascript Code follows. Movie "TestMovie" is a SWF containing ExternalInterface.addCallback("TestFunction",this, TestFunction) ... what it does is not important. The failure is in calling it:
Code:
Expand|Select|Wrap|Line Numbers
- function thisMovie(movieName) {
- if (navigator.appName.indexOf("Microsoft") != -1) {
- return window[movieName];
- }
- else {
- return document[movieName];
- }
- }
- var MyObject = new Object();
- MyObject.SWF = thisMovie("TestMovie");
- // This works in all browsers:
- MyObject.SWF.TestFunction();
- // Works in IE, but crashes in Firefox:
- var wtf = MyObject.SWF.TestFunction;
- wtf();