2

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?

Community
  • 1
  • 1
RMD
  • 3,421
  • 7
  • 39
  • 85

1 Answers1

0

I'm not 100% clear if I understand you question but check out the last section on this page:

http://www.infimum.dk/HTML/JSwindows.html

I hope it helps.

jcmitch
  • 2,088
  • 9
  • 27
  • 33
  • Due to the fact that FrameA may be reloaded, any attempt to have FrameB execute a function in FrameA via a variable that contains a pointer to that function can result in the "freed script" error I previously mentioned. See http://stackoverflow.com/questions/8408358/cant-execute-code-from-a-freed-script for more details. – RMD Dec 07 '11 at 21:06