miuim
3/10/2015 - 1:50 AM

Change the tab name in browser

Change the tab name in browser

var a = document.title;

window.onblur = function() {
    document.title = "♬ Baby come back! Any kind of fool could see... ♬";
}, window.onfocus = function() {
    document.title = a;
};
<html>
    <head>
        <title>Demo: 离开页面时修改浏览器标签名称</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <h1>Demo: 离开页面时修改浏览器标签名称</h1>
        <div>
          <p>不要关闭这个页面;</p>
          <p>将浏览器标签切换到任意其他页面;</p>
          <p>注意到浏览器标签名称的变化了吗?</p>
          <p><a href="https://miu.im/change-the-tab-name-in-browser/">← 回到 Let's whisper 的相关文章</a></p>
        </div>
    </body>
</html>

Change the tab name in browser

change the tab name in browser when user go off this page

A Pen by whisperer on CodePen.

License.