Web Page Launch using node Template in dashboard with two tabs

Hi,
I have a dashboard with two screens (tabs). The first has a button that when clicked opens a web page in the browser, using the node template with an HTML program. When I go to the second screen and return to the first, the web page always launches even without me clicking the button. Any suggestion?

Thanks,
Roberto

I am no expert but it seems likely that something triggers the input to the template node when you return to the second tab. Set a debug on the input to the node to see where it is coming from. You could try the ui_control node to stop this.

Hi Bucksin,

I did the debug, and the web page triggering is done internally by node-red without triggering my nodes. I attach a very simple program that shows the problem. If you want to see this challenge, click on the web page, switch to screen 2 and return to screen 1. You will see that the web page is always displayed.

Thanks

WebPageTest.txt (6.9 KB)

This behavior is called the "replayMessage". It can't be turned off just like that so you'll have to live with that. For sure it does not allow you to create links in the way you did.

I think you are trying to have one button but depending on some state you want it to open different urls, just use simple ui_template with something like this:

<a href="{{msg.payload}}" target="_blank">
    <button style="background-color: blue; color: white;">Click Me!</button>
</a>

And from server side send it correct url whenever it needs to be updated.

Also if you use a named target window instead of _blank - at least it will only open the same window and not a new one each time.

Hi dears,

I believe that after several attempts, I get to solve it, and I thank everyone for their help. The solution is to clean the template after using it, adding a new node function:

msg.template = "";
return msg;

Best Regards,

Roberto

image

Can't really understand why such simple thing must be done with that kind of overkill solution ...but hey.. It's done :slight_smile:

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