# \*\*how to close node-red browser window by a button in dashboard\*\*

**URL:** <https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699>\
**Category:** Dashboard\
**Created:** [13 December 2023 21:55 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699 "2023-12-13T21:55:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)\
**Post date:** [13 December 2023 21:55 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/1 "2023-12-13T21:55:36Z")

</div>

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?

Thanks for your help in advance

Tim

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 December 2023 22:09 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/2 "2023-12-13T22:09:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [14 December 2023 00:32 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/3 "2023-12-14T00:32:45Z")

</div>

I had asked a similar question sometime ago....

> [@Close only the current tab of Browser (showing the dashboard) from dashboard](https://discourse.nodered.org/t/close-only-the-current-tab-of-browser-showing-the-dashboard-from-dashboard/57537):
>
> Hi, [{"id":"e86f1613ede2bc54","type":"exec","z":"d12f70e7abaacb43","command":"TASKKILL /IM msedge.exe /F","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":1540,"y":80,"wires":[["59d076f1d8438796"],["bfab2bcacd99742b"],["a91d06aa99828246"]]}] [image] I am able to CLOSE all the open sessions of MS Edge Browser through EXEC node by using command TASKKILL /IM msedge.exe /F How can i close only the current TAB from which the Button to run EXEC node…

---

<div class="post-metadata">

**Author:** ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)\
**Post date:** [14 December 2023 07:21 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/4 "2023-12-14T07:21:18Z")

</div>

Hi Collin,  
i only want to close the tab with the node-red dashboard

Regards

Tim

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [14 December 2023 07:37 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/5 "2023-12-14T07:37:19Z")

</div>

ctrl+w should work..

---

<div class="post-metadata">

**Author:** ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)\
**Post date:** [15 December 2023 20:40 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/6 "2023-12-15T20:40:21Z")

</div>

Thanks for the answer but how can I put that in an exec node? What is the unicode for control+w ?  
How to send this from a button in the dash?

Regards Tim

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [16 December 2023 00:06 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/7 "2023-12-16T00:06:13Z")

</div>

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.

See: [javascript - How to close current tab in a browser window? - Stack Overflow](https://stackoverflow.com/questions/2076299/how-to-close-current-tab-in-a-browser-window)

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [16 December 2023 01:02 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/8 "2023-12-16T01:02:32Z")

</div>

Try this ui\_template. _Use at your own risk._

```auto
[{"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}]

```

Inspired by this earlier post...

> [@Sendkeys to enter fullscreen](https://discourse.nodered.org/t/sendkeys-to-enter-fullscreen/4642/8):
>
> I asked bard to help me and this is what it gave and i inserted this into a template node, and it works! [{"id":"911e3d0e.7d6e9","type":"ui\_template","z":"28a414e3a8847f5a","group":"5a956c96.cfca64","name":"","order":2,"width":0,"height":0,"format":"\<script\>\nvar elem = document.documentElement;\n// or overwrite value in your callback function ...\n\nthis.scope.action = function toggleFullscreen() {\n var element = document.body;\n if (document.fullscreenElement) {\n document.ex…

---

<div class="post-metadata">

**Author:** ![tim26](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tim26](https://discourse.nodered.org/u/tim26)\
**Post date:** [16 December 2023 21:13 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/9 "2023-12-16T21:13:32Z")

</div>

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

[flows (8).json](https://discourse.nodered.org/uploads/short-url/rqYsp7ZCYF7LPBKBG90jOIvDZIc.json) (1.5 KB)

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [17 December 2023 02:56 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/10 "2023-12-17T02:56:28Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/8/f8a3c35a3e5f894944279b4a066702299092a40e.png)

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/9560b9eeddab6d78ef095241f05e1bfdd80a1a8e.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 December 2023 02:57 UTC](https://discourse.nodered.org/t/how-to-close-node-red-browser-window-by-a-button-in-dashboard/83699/11 "2023-12-31T02:57:23Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
