-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node-Webkit: Child window to call parent window #456
Comments
The working approach is probably initiating a call from the parent window to its child after the Try the following in childwin.on('loaded', function(){
childwin.window.haveParent(mainwin);
}); and the following in function haveParent(theParent){
theParent.window.changeparentmethod();
} |
Thanks Mithgol, Click me ';var newpopup = window.open('popup.html', 'Test Popup'); newpopup.document.write(popContent); newpopup.document.close(); var testpop = gui.Window.get(newpopup); testpop.on('loaded', function(){ console.log('came loaded testpop'); testpop.window.haveParent(win); }); function changeparentmethod() { console('Called & Came main window'); mainwin.show(true); } ++++++++++++++++++++++++++++++++++++++++++++++++++++ popscript.js->inside(popup.html) file ++++++++++++++++++++++++++++++++++++++++++++++++++++ var gui = require('nw.gui'); var win = gui.Window.get(); function haveParent(theParent){ console.log('came haveParent'); parentwindowcontrol(theParent); } function parentwindowcontrol(parentwindow) { console.log("came parentwindowcontrol"); document.onclick = docclickhandler; function docclickhandler() { parentwindow.window.changeparentmethod(popup); }
++++++++++++++++++++++++++++++++++++++++++++++++++++ Please check it and update me how to implement? |
here is my code,just modified a little from yours @anandh :
and it works ok for me. maybe you could just use |
I got this Error in console while running above code
|
@Freddy-tech that's because be.Window.open has changed from nw13 and onwards. See the latest documentation. |
Thanks i found Solution it was simple with pure JavaScript |
My god. what are you getting wrong English? Oh :( hasParent() is correct because Adobe System writes clean like AS3 has "has[variable-functionname]" example hasEvent, hasProprety or whatever Please change "haveParent" to "hasParent" because window = it that is why It has - But "have" means "we have" or "they have" or "you have". That is wrong. Thanks for changing alphabets. Thanks! |
Hi Everybody,
I have created one main window & child window ,
Parent window code:mainwin.html
++++++++++++++++++++++++++++++++++++++++++++++++++++++
var mainwin = gui.Window.get();
var childwin = gui.Window.open('childwin.html', {
x: 100, y: 100, width: 200, height: 300
});
function changeparentmethod()
{
alert('came main');
mainwin.show(true);
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++
inside childwin.html file, Can i call the any mainwin window methods and properties like below ?
Child window code:childwin.html
++++++++++++++++++++++++++++++++++++++++++++++++++++++
var currwin = gui.Window.get();
currwin.opener.changeparentmethod();
++++++++++++++++++++++++++++++++++++++++++++++++++++++
For this i am getting an error, how to implement this functionality??
In javascript opener method is working fine.
The text was updated successfully, but these errors were encountered: