In the scenario where I have two frames within a window, Frame A and Frame B.
In order to invoke a function from Frame A while being in Frame B, I utilize the following code:
parent.frames['mainframe'].myfunction();
The challenge arises when there is a possibility that the function does not exist in Frame A.
My objective is to verify its existence before making the call.
Although my attempt resulted in a JavaScript error.
if ( typeof parent.frames['mainframe'].myfunction == 'function' ) {
//function_name is a function
}
Error:
TypeError: undefined is not a function
Update:
To address the issue raised by all of you, it appears that the actual code run had the parentheses included - typeof parent.frames['mainframe'].myfunction(). Apologies for the confusion. How should I proceed regarding the best answer?