change the tab name in browser when user go off this page
Last active
August 29, 2015 14:16
-
-
Save miuim/8cde7928816f597096b0 to your computer and use it in GitHub Desktop.
Change the tab name in browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = document.title; | |
window.onblur = function() { | |
document.title = "♬ Baby come back! Any kind of fool could see... ♬"; | |
}, window.onfocus = function() { | |
document.title = a; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment