Can Node-red force browser to reload the editor?

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

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?

You can use the ClientCode 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:

1 Like

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.

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.

:slight_smile: Thank you, glad it helped!

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.

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
shows nothing in Firefox after a reboot without a manual reload.

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

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