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

StackOverflow https://stackoverflow.com/questions/14146922

  •  12-01-2022
  •  | 
  •  

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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top