# Set window title through payload

**URL:** <https://discourse.nodered.org/t/set-window-title-through-payload/33504>\
**Category:** Dashboard\
**Created:** [29 September 2020 09:52 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504 "2020-09-29T09:52:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mj-123](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@mj-123](https://discourse.nodered.org/u/mj-123)\
**Post date:** [29 September 2020 09:52 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/1 "2020-09-29T09:52:24Z")

</div>

Hi,

how to set document.title at runtime through a payload variable?  
Is it somehow possible to call the angular function [setTitle](https://angular.io/guide/set-document-title) in an ui\_template node?

Thanks,  
Manuel

---

<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:** [29 September 2020 10:12 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/2 "2020-09-29T10:12:12Z")

</div>

This might help

> <https://stackoverflow.com/questions/12506329/how-to-dynamically-change-header-based-on-angularjs-partial-view/14565132#14565132>

---

<div class="post-metadata">

**Author:** ![mj-123](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@mj-123](https://discourse.nodered.org/u/mj-123)\
**Post date:** [29 September 2020 10:44 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/3 "2020-09-29T10:44:32Z")

</div>

Thanks for the hint but unfortunately I am not getting it.  
So at least this test does not work out:

```auto
[
    {
        "id": "a95fc7a5.559d7",
        "type": "ui_template",
        "z": "912f241f.87cae8",
        "group": "4a6429b4.097758",
        "name": "setWindowTitle",
        "order": 0,
        "width": 0,
        "height": 0,
        "format": "<script>\n (function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) {\n $window.document.title = msg.payload;\n }\n });\n })(scope);\n</script>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "templateScope": "global",
        "x": 760,
        "y": 200,
        "wires": [
            [
                "aa7a0149.a3f72"
            ]
        ]
    },
    {
        "id": "196f9a72.f381a6",
        "type": "inject",
        "z": "912f241f.87cae8",
        "name": "",
        "topic": "",
        "payload": "test",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 590,
        "y": 200,
        "wires": [
            [
                "a95fc7a5.559d7"
            ]
        ]
    },
    {
        "id": "aa7a0149.a3f72",
        "type": "debug",
        "z": "912f241f.87cae8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 930,
        "y": 200,
        "wires": []
    },
    {
        "id": "4a6429b4.097758",
        "type": "ui_group",
        "z": "",
        "name": "test",
        "tab": "a15e3d6a.2ebff",
        "order": 2,
        "disp": false,
        "width": "10",
        "collapse": false
    },
    {
        "id": "a15e3d6a.2ebff",
        "type": "ui_tab",
        "z": "",
        "name": "test",
        "icon": "",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<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:** [29 September 2020 10:54 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/4 "2020-09-29T10:54:55Z")

</div>

Well that's what I would have done probably so if it isn't working, I don't know why I'm afraid.

Put some `console.log` statements into the ui\_template code to make sure you are getting what you expect and when. Also check your browser console to see if there are any errors.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [29 September 2020 12:01 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/5 "2020-09-29T12:01:48Z")

</div>

The `ui_template` can't be targeted to site head but should be widget in the group.  
And you don't have `$window.document` so use window.document instead

---

<div class="post-metadata">

**Author:** ![mj-123](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@mj-123](https://discourse.nodered.org/u/mj-123)\
**Post date:** [29 September 2020 12:43 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/6 "2020-09-29T12:43:25Z")

</div>

Thank you hotNipi, that was the trick.

---

<div class="post-metadata">

**Author:** ![hbull1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hbull1/32/28929_2.png) [@hbull1](https://discourse.nodered.org/u/hbull1)\
**Post date:** [30 September 2020 18:40 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/7 "2020-09-30T18:40:35Z")

</div>

I haven't been able to get this to work. @hotNipi do you have a sample flow I could import and try?

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [30 September 2020 19:05 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/8 "2020-09-30T19:05:25Z")

</div>

That same flow what was shared by @mj-123 works well if you apply those changes I mentioned.

I'm on the phone currently so no flow sharing for me...

---

<div class="post-metadata">

**Author:** ![hbull1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hbull1/32/28929_2.png) [@hbull1](https://discourse.nodered.org/u/hbull1)\
**Post date:** [1 October 2020 02:34 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/9 "2020-10-01T02:34:30Z")

</div>

Got it working. Thanks.

---

<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 October 2020 02:34 UTC](https://discourse.nodered.org/t/set-window-title-through-payload/33504/10 "2020-10-15T02:34:33Z")

</div>

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