# Howto: Dashboard button link to url with no UI template for only the current user on the page

**URL:** <https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210>\
**Category:** Dashboard\
**Created:** [23 September 2020 05:30 UTC](https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210 "2020-09-23T05:30:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [23 September 2020 05:30 UTC](https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210/1 "2020-09-23T05:30:02Z")

</div>

I've seen a form of this question popup here from time to time.  
Many of us are not html gods and can't do much in the UI template node. And it does not format to the nice dashboard style without tons of css work.

Yes you can add a link to the dashboard and use the UI node to send people there based on a action. But anyone on that tab will be forwarded too as dashboard is not (mostly) a multi user system.

Then a crazy thought entered my head. The dashboard notification node.  
 ![notification](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28405bf5f785790cb782bf74d29002141cb6c6e9.jpeg)  
It allows for html and javascript to be in the msg.payload and you can ![nodesettings](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/65ca37f2b5ab1cfa08e6ed4340e858df7bada736.jpeg)

So can it be as simple as formatting a javascript redirect like this:

```auto
<!DOCTYPE html> 
<html> 
<head> 
    <title>Redirect url to node-red forum</title> 
</head> 
<body> 
<script> 
    var url= "https://discourse.nodered.org"; 
    window.location = url; 
</script> 
</body> 
</html>

```

Into a properly formatted payload for the notification node? Will it work?  
The answer is YES!!!!!

try out this:

 ![button_flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e5eb06a062f8092358914b17d2d277f1e956be26.jpeg)

```auto
[{"id":"33fb0d2f.a7833a","type":"change","z":"1ca6ee4c.4e6bfa","name":"msg.url = https://google.com","rules":[{"t":"set","p":"url","pt":"msg","to":"https://google.com","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":360,"wires":[["415f23cf.2bd96c"]]},{"id":"deda1028.07bb2","type":"ui_button","z":"1ca6ee4c.4e6bfa","name":"","group":"63d32bef.5e22d4","order":0,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":190,"y":360,"wires":[["33fb0d2f.a7833a"]]},{"id":"9ac06d0e.371","type":"function","z":"1ca6ee4c.4e6bfa","name":"Format Payload for notification node","func":"msg.payload = '<!DOCTYPE html><html><head><title>Redirect url to node-red forum</title></head><body>'+msg.notification_to_user+'<script>var url= \"'+msg.url+'\"; window.location = url; </script></body></html>';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":420,"wires":[["90b001d7.385da"]]},{"id":"415f23cf.2bd96c","type":"change","z":"1ca6ee4c.4e6bfa","name":"notification msg to user = Redirecting","rules":[{"t":"set","p":"notification_to_user","pt":"msg","to":"Redirecting","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":360,"wires":[["9ac06d0e.371"]]},{"id":"90b001d7.385da","type":"ui_toast","z":"1ca6ee4c.4e6bfa","position":"top right","displayTime":"1","highlight":"","sendall":false,"outputs":0,"ok":"OK","cancel":"","raw":true,"topic":"","name":"","x":560,"y":420,"wires":[]},{"id":"63d32bef.5e22d4","type":"ui_group","z":"","name":"button_for_URL","tab":"dfde7706.43a3e","order":1,"disp":false,"width":"6","collapse":false},{"id":"dfde7706.43a3e","type":"ui_tab","z":"","name":"testing_button","icon":"dashboard","disabled":false,"hidden":false}]

```

You don't have to use a button. Any logic you use that triggers the notification will forward the user.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 September 2020 12:55 UTC](https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210/2 "2020-09-23T12:55:11Z")

</div>

> [@meeki007](#):
>
> ```auto
> <script> 
> var url= "https://discourse.nodered.org"; 
> window.location = url; 
> </script> 
> 
> ```

Nice find. Though I might have assumed that including the above in a ui\_template node might do the same thing and certainly wouldn't impact the layout in any way.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [23 September 2020 15:36 UTC](https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210/3 "2020-09-23T15:36:16Z")

</div>

If you add a ui\_template node with just

```auto
<script> 
    var url= "https://discourse.nodered.org"; 
    window.location = url; 
</script> 

```

it will send / forward anyone and anything to [https://discourse.nodered.org](https://discourse.nodered.org) without pause or logic.  
basally any location of the /ui/#!/anything will be forwarded

you never get a chance to interact with the dashboard

also it does not solve the problem of only forwarding the user using that socketid

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 September 2020 20:57 UTC](https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210/4 "2020-09-23T20:57:48Z")

</div>

Ah true, you would need some extra logic. Good points. Very helpful.

---

<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:** [23 October 2020 20:58 UTC](https://discourse.nodered.org/t/howto-dashboard-button-link-to-url-with-no-ui-template-for-only-the-current-user-on-the-page/33210/5 "2020-10-23T20:58:01Z")

</div>

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