If I do this:
var new_win = window.open();
How do I make it so that all of the functions that could be used in the parent window can now be used in the child window (new_win
)?
I do not want to do:
var fun1 = window.opener.fun1;
var fun2 = window.opener.fun2;
...
Please note that what follows is a dangerous, dirty, messy, M$-level hack. I am fully aware of this, but it (theoretically) does what @Neal wants. (I'm a little scared to even post it, and I fully expect downvotes)
In light of the scope issues, I've determined that we must use
.bind
. There is a shim at the MDN Entry for Function.bind which will be necessary for certain browsers.Please note that before using
.bind
, the code must check to see if the property is a function. I have done this along with thehasOwnProperty
checks, but if you wish to transfer values as well as functions, you may want to do this within its ownif
statement.