Justinas Dūdėnas
Justinas Dūdėnas

Reputation: 161

window.close() stops working in node-webkit after navigating away from the main html

I have two html files in a prototype. If I open any of them, a closing button does the job.

<img  src="img/x-01.png" onclick="window.close()" />

After I navigate to another html, the same code sample stops working. And doesn't work even if I come back to the previous page via browser`s "back" button.

How could that be? I'm new to js, so is there some concept I don't understand?

As the code is scattered among several files, I uploaded a stripped-down app - for observing this behaviour.

Upvotes: 3

Views: 1956

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114367

window.close() can only be called by the same page that opened the window in the first place (otherwise third-party web pages would be closing windows on us at will). Once you navigate away, you lose this connection and ability.

Upvotes: 3

Related Questions