# How to get address of the browser instance

**URL:** <https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [14 September 2021 15:53 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024 "2021-09-14T15:53:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)\
**Post date:** [14 September 2021 15:53 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/1 "2021-09-14T15:53:03Z")

</div>

Far from me the idea of relaunching the debate on multi-user dashboard. I understood that it was not made for !  
That said, my application is not fully multi-user: I have 2 user groups. An admin type will have access to all functions. The other no: I just have 3 buttons to disable.  
To do this, is it possible one way or another, to retrieve the address appearing in the address bar of the web browser: thus, I will be able to retrieve the user's socketid and carry out my routing in function.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [14 September 2021 19:38 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/2 "2021-09-14T19:38:33Z")

</div>

If you disable 3 buttons for the 1e user, then the will also be disabled for the other users.

I'm using the ip address of a specific user (tablet living room vs tablet bed room) to do some different actions. For me, load a different floorplan for the different tablets as default.

With **ui\_control** you can get **Getchanges** and filter the ip address out with **msg.socketip**.

Maybe this can help you, have fun.

```auto
[{"id":"c6c67e1c.63cb1","type":"ui_ui_control","z":"b3f31bbd.8966b8","name":"GetChanges","events":"change","x":130,"y":140,"wires":[["3b5784d6.3a6fc4"]]},{"id":"3b5784d6.3a6fc4","type":"switch","z":"b3f31bbd.8966b8","name":"Device 192.168.0.151","property":"socketip","propertyType":"msg","rules":[{"t":"eq","v":"192.168.0.151","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":360,"y":140,"wires":[["75e63278.81e8bc"]]}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [14 September 2021 20:56 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/3 "2021-09-14T20:56:02Z")

</div>

You can get the browser url as below.  
add one for each tab, when tab loads the url will be sent in the payload.

```auto
[{"id":"197cb9b.8e143c6","type":"ui_template","z":"b779de97.b1b46","group":"ada4e0c8.ca2d58","name":"","order":0,"width":0,"height":0,"format":"<script>\n(function(scope) {\n scope.send({payload: window.location.href}); \n})(scope);\n</script>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":450,"y":3520,"wires":[["1adc3f5c.41ec09"]]},{"id":"1adc3f5c.41ec09","type":"debug","z":"b779de97.b1b46","name":"","active":true,"console":"false","complete":"false","x":719,"y":3520,"wires":[]},{"id":"ada4e0c8.ca2d58","type":"ui_group","z":"b779de97.b1b46","name":"Default","tab":"e4c8df5a.bc9048","order":1,"disp":true,"width":"6"},{"id":"e4c8df5a.bc9048","type":"ui_tab","z":"b779de97.b1b46","name":"tab2","icon":"dashboard"}]

```

```auto
<script>
(function(scope) {
    scope.send({payload: window.location.href});  
})(scope);
</script>

```

[edit]  
you can also get the port , hostname and more if required

> **[Location - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location)**
>
> The Location interface represents the location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and...

---

<div class="post-metadata">

**Author:** ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)\
**Post date:** [15 September 2021 07:08 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/4 "2021-09-15T07:08:22Z")

</div>

Thank you for your reply. Your idea is indeed interesting. My problem is that a priori, I can not know the fixed IP addresses of the computers to be connected. But I retain your solution for possible future projects.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 September 2021 09:10 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/5 "2021-09-15T09:10:49Z")

</div>

> [@SergioRT](#):
>
> I can not know the fixed IP addresses of the computers to be connected.

@E1cid suggestion will return the IP address in `msg.socketip` of whatever device connects to the dashboard. Here is what I get connecting from an iPhone:  
 ![Screen Shot 2021-09-15 at 5.09.42 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae354457b3e574ed25afa77c3f0e3dfb2337f8fa.png)

---

<div class="post-metadata">

**Author:** ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)\
**Post date:** [15 September 2021 12:28 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/6 "2021-09-15T12:28:10Z")

</div>

thanks for all !

---

<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:** [29 September 2021 12:28 UTC](https://discourse.nodered.org/t/how-to-get-address-of-the-browser-instance/51024/7 "2021-09-29T12:28:49Z")

</div>

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