开发者

Calling function passed to child window, relative to child window

I've tried almost everything to get this to work. It is really best explained with excerpts from the code.

function loadWindow() {

var newWin = window.open("","win_1","");        
newWin.newObject = new tableObject(function(){window.document.write('test');});
newWin.document.close();
}

There is code written, not displayed to make it more readable, but开发者_如何学JAVA it writes more html to the child page.

Part of what it writes in the second page is onMouseDown='newObject.next();' which is passed to the tableObject by the constructor function tableObject(nextClick) {this.next = nextClick}.

when I call the function it causes an error, but does write test to the parent window, not the child.

I would like it to write to the child and not causes any error :-/.

I have been working on this for days, and would be very thankful for any help. If you need any more of my code visible, let me know.


I think I solved this and wanted to explain the solution. The reason the anonymous function is calling window.document.write(""); relative to the parent window is becuase is is closed on all free variables when it is assigned to the object. So when I call it in the child it references the parent window where is was assigned not the child.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜