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)
var i, w = window.opener;
for (i in w)
{
if (w.hasOwnProperty(i) && !window.hasOwnProperty(i) && typeof w[i] === 'function')
{
window[i] = w[i];
}
}
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 the hasOwnProperty
checks, but if you wish to transfer values as well as functions, you may want to do this within its own if
statement.
var i, w = window.opener;
for (i in w)
{
if (w.hasOwnProperty(i) && !window.hasOwnProperty(i) && typeof w[i] === 'function')
{
window[i] = w[i].bind(window);
}
}