Internet Explorer 6/7/8.
I'm using the eval() calls to ensure that code is executed within the context of particular frames within a multi-frame web site.
The situation I have is that I'm basically passing the fully qualified name of a method in FrameA to FrameB. I then want FrameB to execute said method inside FrameA - but from within the context of FrameA. This is critical due to a limitation inside IE that can result in "freed script" errors otherwise. See: Can't execute code from a freed script
FrameB uses eval to first get the target frame object, and then it calls eval on the resulting object to execute the method that lives within that frame. So consider the following executing from inside FrameB:
eval("top.FrameA").eval("SomeMethod(1,2);");
The first eval returns a window object, but the call to the second eval always results in an "object expected" error.
Interestingly, the above code works from inside FrameA, but it is in fact being executed inside FrameB via the following code:
top.FrameB.eval("eval('top.FrameA').eval('SomeMethod(1,2);');");
So the problem has something to do with the nesting of the eval statements.
What am I missing here?