Page 1 of 1

Browser Tab get matching name(s) of viewing page(s)

Posted: Thursday 24 November 2022 13:16
by mzonneveld
A small jQuery addition to set the browtitle to the current page.
So when opening mulitple tabs, it's easy to see which tab shows which DZ-page.

Image

Code: Select all

$(function () {
    // Init Events
    $(window).on('hashchange', function () { UpdateOnNavigate(); });
    $("#appnavbar a[href]").click(function () { UpdateOnNavigate(); });
    UpdateOnNavigate();
}); // Doc Ready

function UpdateOnNavigate() {
    // Update browser titel
    titel = location.href;
    if (titel.indexOf('#') >= 0) {
        titel = titel.split('#')[1].replace('/', '') + ' - DZ';
        titel = titel.trim(' ').trim('-');
        document.title = titel;
    }
}

Re: Browser Tab get matching name(s) of viewing page(s)

Posted: Thursday 24 November 2022 17:13
by waltervl
I would suggest you make a PR in the github repositories so this will be part of all releases. Else you have to update the scripts at every Domoticz (beta) update.