I have a function defined on the window object somewhat like this
window["functionName"] = function(){
// code here
};
Now whenever I need that function I just call
window["functionName"]();
This works well in all browsers except IE8. IE8 throws an error
SCRIPT438: Object doesn't support property or method 'functionName'
I googled for explainations but didnt find any.
EDIT: After a long time debugging I got the cause of the error
Actually the above function definition was inside another function.
function otherFunction(){
window["functionName"] = function(){
// code here
};
// code here
}
When I moved it outside it looked to work fine.
window["functionName"] = function(){
// code here
};
function otherFunction(){
// code here
}
But I still cannot understand why this weird behaviour?