How to listen for changes to the title element?

后端 未结 4 1875
渐次进展
渐次进展 2020-12-01 05:18

In Javascript, is there a technique to listen for changes to the title element?

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 06:10

    This's my way, in a closure and check in startup

    (function () {
        var lastTitle = undefined;
        function checkTitle() {
            if (lastTitle != document.title) {
                NotifyTitleChanged(document.title); // your implement
                lastTitle = document.title;
            }
            setTimeout(checkTitle, 100);
        };
        checkTitle();
    })();
    

提交回复
热议问题