![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
|
parent.document.foo(); // also tried... top.document.foo(); |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
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. |
#7
| |||
| |||
|
|
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. If I'm right, I believe that's because functions are primitive data types in JS, like strings and numbers, |
|
so they're passed "by value" in all operations, and not by reference. snip |
#8
| |||
| |||
|
|
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. If I'm right, I believe that's because functions are primitive data types in JS, like strings and numbers, Functions are object in javascript. And like all other objects they can have named properties added to them, and assigned values, at any time. so they're passed "by value" in all operations, and not by reference. snip Being objects they are passed by reference only. Richard. |
#9
| |||
| |||
|
|
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? |
#10
| ||||
| ||||
|
|
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? |
|
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. |
|
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. |
|
-- Martin Honnen http://JavaScript.FAQTs.com/ |
![]() |
| Thread Tools | |
| Display Modes | |
| |