简体   繁体   English

如何以编程方式关闭在 Kiosk 模式下运行的 Chrome?

[英]How to close Chrome running in Kiosk mode programmatically?

I have an Angular 9 app running in Chrome which itself is running in Kiosk mode.我有一个在 Chrome 中运行的 Angular 9 应用程序,它本身以 Kiosk 模式运行。 I need an option to close Chrome since there is no keyboard attached to the PC where the app is running.我需要一个关闭 Chrome 的选项,因为运行应用程序的 PC 上没有连接键盘。

Is there a way to do this programmatically without using an extenstion?有没有办法在不使用扩展的情况下以编程方式执行此操作? A switch to another browser is possible.可以切换到其他浏览器。

I tried to get the window object in Angular and call window.close();我试图在 Angular 中获取window对象并调用window.close(); but it seems as if I didn't get the right one and only a component of the app closed instead of the chrome window.但似乎我没有得到正确的一个,只有应用程序的一个组件关闭而不是 chrome 窗口。

I know that you can't close a window that wasn't opened with JavaScript but going off the comment on this answer I thought that Kiosk mode might be different.我知道你不能关闭一个不是用 JavaScript 打开的窗口,但是关闭这个答案的评论我认为 Kiosk 模式可能会有所不同。

Edit:编辑:

The component closing happened because of a bug in our own software and window.close();组件关闭是因为我们自己的软件和window.close();的一个错误window.close(); doesn't work which is the expected behaviour.不起作用,这是预期的行为。

You can write a watchdog process that will:您可以编写一个看门狗进程,它将:

  • Launch the browser启动浏览器
  • Monitor the window title监控窗口标题

If the window title changes to something like 'TERMINATING - Chrome', which is something you can change from within JavaScript, the watchdog process can kill the browser process.如果窗口标题更改为诸如“TERMINATING - Chrome”之类的内容(您可以在 JavaScript 中更改此内容),则看门狗进程可能会终止浏览器进程。

The watchdog could also restart the browser if it crashes on its own without requesting termination.如果浏览器在没有请求终止的情况下自行崩溃,看门狗也可以重新启动浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM