# Can Node-red force browser to reload the editor?

**URL:** <https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621>\
**Category:** General\
**Tags:** raspberry-pi\
**Created:** [30 April 2024 22:25 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621 "2024-04-30T22:25:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [30 April 2024 22:25 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/1 "2024-04-30T22:25:46Z")

</div>

On the Raspberry Pi you can turn on the read-only overlay filesystem by editing /boot/firmware/cmdline.txt and rebooting, easy enough with exec nodes.

I show the readonly status of the Pi in the editor header, eg  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/857808ea85e0262fa384179c01ac60d269263e5f.png)  
or  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e6270812c42036c6e643a51ff19bb03637676fbe.png)

But it only shows up in the browser when I manually reload. (The browser is not on the Pi but on a PC, so it is not restarted)

So is there a way to force a page reload when the Pi or Node-red starts?

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [1 May 2024 08:56 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/2 "2024-05-01T08:56:11Z")

</div>

You can use the [ClientCode](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-introspection) node - that executes Javascript code in the browser but triggered by a Node-RED server flow.

For example, this will reload the browser by pressing the inject button:

```auto
[{"id":"caefbf26df6e28fc","type":"ClientCode","z":"5e62ac9a3cf72547","name":"","clientcode":"window.location.reload()","format":"javascript","x":1094.4444160461426,"y":665.5555686950684,"wires":[[]]},{"id":"b4010190f671fcae","type":"inject","z":"5e62ac9a3cf72547","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":758.888916015625,"y":670,"wires":[["caefbf26df6e28fc"]]}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 May 2024 12:16 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/3 "2024-05-01T12:16:56Z")

</div>

Thanks very much for that Gerrit.

It does indeed reload the page if I click inject, but setting it to automatically inject after 0.1 sec does not work.  
I think that's an issue with the Inject node - separate thread created.

The work-around is to make the inject node fire after 10 seconds not 0.1 sec.

---

<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:** [1 May 2024 12:30 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/4 "2024-05-01T12:30:42Z")

</div>

This is unlikely to be a problem with the inject node. More likely is that it is happening before the browser has connected, or something along those lines. I would say that increasing the time is the solution, not a workaround.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [1 May 2024 17:07 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/5 "2024-05-01T17:07:19Z")

</div>

> [@jbudd](#):
>
> Thanks very much for that Gerrit.

🙂 Thank you, glad it helped!

> [@Colin](#):
>
> More likely is that it is happening before the browser has connected, or something along those lines.

I would agree, that 0.1 sec is a terribly short time. You could also try a delay node, perhaps that would do a better job.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 May 2024 21:09 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/6 "2024-05-01T21:09:15Z")

</div>

Slight difficulty: I can't get `window.location.reload()` to work in Firefox.

If I change it to `window.location.reload(true)` then it works when I manually inject but not automatic inject at startup, regardless of the delay before injecting.

Indeed even this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/98cdb7174e52aa2f6477acd37c736f1bd195afc4.png)  
shows nothing in Firefox after a reboot without a manual reload.

I guess it's one more reason to switch from Firefox to Brave.

---

<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:** [15 May 2024 21:09 UTC](https://discourse.nodered.org/t/can-node-red-force-browser-to-reload-the-editor/87621/7 "2024-05-15T21:09:55Z")

</div>

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