How can I verify if a function was defined already?
Will this work?
if(window.opener.MyFunctionBlah) { ... }
How can I verify if a function was defined already?
Will this work?
if(window.opener.MyFunctionBlah) { ... }
Yes. Functions are just properties of objects like any other, so you can treat them as such. The conditional you posted above will return true if that function (or any member of window.opener
called MyFunctionBlah
) is defined and non-null.
if( window.opener.MyFunctionBlah && ...
is not necessary because typeof will return 'undefined' if the given property is not defined.
A simple if( typeof window.opener.myFunctionBlah == 'function'
is enough.