Hi, I show a node-red dashboard working on a thin client from a browser window on a control system.
Stupidly I can not leave node-red window any more, there is no close button. Therfore I want to install a button in my dashboard to close the node-red window. (I don't want to stop node-red only want to close the window).
I tried with an execute node and CTR + F4 but it does not work.
Have you any idea how to solve this?
Do you want to close the browser or just the tab showing the dashboard? If you want to close the browser you could send the browser process a signal to shut down.
You can not inject key combinations with the exec node, it just doesn't work that way.
The best you may be able to do is insert window.close() into the page via a template node, it will probably need to be set as an on click action for something like a button and there are strict limitations around the page having not backstack history for it to work on most browsers.
[{"id":"911e3d0e.7d6e9","type":"ui_template","z":"9d1b14cfb6a1526e","group":"325714454937adc5","name":"Close Current Browser Window","order":2,"width":0,"height":0,"format":"<script>\nvar elem = document.documentElement;\n\nthis.scope.action = function closeWindowWithConfirmation() {\nif (confirm(\"Are you sure you want to close the window?\")) {\nwindow.close();\n}\n}\n\ndocument.getElementById(\"close-button\").onclick = closeWindowWithConfirmation;\n\n</script>\n<md-button ng-click=\"send({payload:action()})\">\n Close Window\n</md-button>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":530,"y":160,"wires":[[]]},{"id":"325714454937adc5","type":"ui_group","name":"DEMO","tab":"fb48ae21810a7ddc","order":2,"disp":false,"width":"25","collapse":false,"className":""},{"id":"fb48ae21810a7ddc","type":"ui_tab","name":"TEST","icon":"dashboard","order":7,"disabled":false,"hidden":false}]
Thank you all for your help!
This works for me.
There is only one restriction. When i open node-red dashboard by a link from another website it works.
Is does not work when i type in the adress in the browser adresslist
obviously there are some security related restrictions on closing windows that were not opened by another script. there are worka arounds for it also, but several warning signs around them, so i would not suggest.