Skip to content
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

Window.open callback returns undefined for new window #4188

Closed
eemi2010 opened this issue Jan 8, 2016 · 25 comments
Closed

Window.open callback returns undefined for new window #4188

eemi2010 opened this issue Jan 8, 2016 · 25 comments

Comments

@eemi2010
Copy link

eemi2010 commented Jan 8, 2016

nw.Window.open('https://github.com', {}, function(new_win) {
console.log(new_win);
});

new_win is randomly undefined. So if you run the code lets say 5 times. You might get undefined 2 times

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@AndryBray
Copy link

I can confirm this issue with latest nightly build (2016-01-08) on MacOS

@AndryBray
Copy link

@rogerwang I see this problem every time I execute this on latest nwjs 0.13 beta3 (Jan 12)

nw.Window.open('http://www.google.com', {}, function(w) {
   console.log('nw window', w);
});

any news about that?

@thib3113
Copy link

same problem with beta4 on windows . new_win is randomly indefined

@berlincount
Copy link

same on beta4 and beta5

@berlincount
Copy link

oh, I'm using new_win = nw.Window.open(url, options), btw, an expecting the same as I'd get from window.open() in a browser ...

@rogerwang
Copy link
Member

Does this happen only with remote sites? It should have been fixed in the nightly build.

@AndryBray
Copy link

@rogerwang I had this problem even with local pages. I will test next build ASAP

@AndryBray
Copy link

Hello @rogerwang
the bug is still there in latest 0.13

Any workaround for the moment?

@AndryBray
Copy link

tested on nwjs 0.14... bug is still there =(

@rogerwang
Copy link
Member

It works for me because we have a test case for this scenario: https://github.com/nwjs/nw.js/tree/nw13/test/remoting/open-remote

See test.py for the content of index.html it generates on the fly.

Is it different from yours?

@thib3113
Copy link

I have the same problem with the version 0.13.0-rc3sdk , but it's not all time ... maybe one time for 10 tests .

@rogerwang
Copy link
Member

@thib3113 could you please upload a sample for the random error? Our test case 'open-remote' never fail so I cannot reproduce it.

@thib3113
Copy link

I juste use this :

gui.Window.open('http://www.XXXXX.com/forum/notifications.html', {
      position: 'center',
      width: screen.availWidth,
      height: screen.availHeight,
      show : false,
  },
    function(cWindows){
        cWindows.on('error', function(a,b,c){
            debugger;
        });
});

With devtools open, and some time i see

on is not a function of undefined

(not sure is the exact error message, but it is like the error)

But, i don't know if the problem is : the website, my connection (I use my phone connection, so lot of connection problems), or other ...

@AndryBray
Copy link

@rogerwang any news about this issue?
I see I have the param "node-remote" set to my domain inside the package.json.

In your test case you don't have any "node-remote". Maybe try to set it and test again.
The problem is still there even with latest of 0.14.
Thank you

@RohitSharma27
Copy link

nw 0.13.0
@rogerwang I can see the same issue as commented by @thib3113 . And it happens in opening a new window and loading local html file in it. The callback in the
Window.open(... , ... , function(win){})
function says "win" is undefined and if I use
win.on('loaded', function(){})
then it sometimes work and sometimes don't by saying "win.on" is not a function of undefined. (Same as reported by @thib3113

@rogerwang
Copy link
Member

@softoxy
Copy link

softoxy commented May 12, 2016

In 0.14.4 the problem is still present.

@softoxy
Copy link

softoxy commented May 12, 2016

I found the solution in 0.14.4, i am changed the approach:

window.opener.closeSplashscreen();

@AndryBray
Copy link

#4844 (comment)

@walton007
Copy link

any update? I also meet this issue and don't know how to workaround?
my case is:

  1. first index.html open one sub_index.html
  2. in the sub_index.html, i open another sub_sub_index.html
    then, sub_sub_index.html is opened. but the Window.open(cb) returns undefined! I just lost control of the new created windows!
    Any one know how to workaround??

@AndryBray
Copy link

AndryBray commented Sep 5, 2016

@walton007 what is your nwjs version? did you try with 0.17?

@tiegeda
Copy link

tiegeda commented Jan 4, 2017

I reproduce it use remote url and set dns to invalid ip. nw.window.open callback a undefined
(when I was trying to deal with timeout, I want to redirect when timeout, but got a undefined)
nwjs 0.14.7

@cyc0der
Copy link

cyc0der commented Jan 11, 2017

same problem for me on winddows
win == undefined
` var gui = require('nw.gui');

		  var win = gui.Window.open ('print.html', {
		  position: 'center',
		  width: 901,
		  height: 127
		  });

		  win.on ('loaded', function(){
			var parameters = {greeting: "Hello World"}
			win.emit("data", parameters);
		  });`

@timraasveld
Copy link

timraasveld commented May 18, 2017

For me, the undefined win was caused by loading a not-found HTML file. If you want to know if this is the cause of your problem as well, put about:blank as the first argument, which should always work if your nwjs version is fine:

nw.Window.open('about:blank', {}, function(win) {
  if(win) {
    console.log("win is no longer undefined!");
  }
);

@ghost
Copy link

ghost commented Jan 13, 2018

I am having this problem, and it doesn't even work with about:blank...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests