Martin Honnen wrote:
> Christopher J. Hahn wrote:
>
>
> >>>Razzbar wrote:
> >>>
> >>>>What's especially neat is that you can assign a new
> >>>>function to the top window from the iframe, then load
> >>>>another document in the iframe, and the top window's
> >>>>new function is still available.
>
> > Not to be argumentative, but if they are passed by reference only then
> > could you explain why the referant isn't freed, causing an error in the
> > case described by Razzbar?
>
> What does pass by reference or value have to do with the case of frames?
Assign an object created in a child frame to a property of the parent
window, then navigate away from that document in the child frame and
attempt to manipulate the object in the parent window, and then maybe
you can tell me.
"Can't execute code from a free script."
> If you have a global variable in one frame then it is a property of the
> window object of the frame thus if the iframe document does
> parent.varName = someExpression
> then a global variable in the parent window is set and that variable
> does not change if a new document is loaded into the iframe as the
> iframe has its own window object with its own variables.
True, but if the variable is set as a reference (i.e. the object is
passed by reference to the assignment operator) then upon navigation of
the frame the referrant will been freed and the reference broken. In my
experience, further attempts to manipulate that object will result in
the error (in IE at least):
"Can't execute code from a freed script."
Try it out, as above.
This does not appear to be the case with functions or primitive values.
> Whether that expression evaluates to a primitive value or a function
> object does not matter at all, there is not even a method or function
> with arguments involved where the term passing by reference or value
> makes sense.
It is a function of operators that they receive values of some kind,
whether they be primitive values or references to objects (see also the
statement: ;+; ). I have commonly seen this provision of values to an
operator referred to as "passing". You might call it something else. It
makes no difference.
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/