Javascript 设置浏览器标题栏,显示当前时间

setInterval(function(){
	var now = new Date();
	var h = now.getHours();
	var m = now.getMinutes();
	var s = now.getSeconds();

	h = h < 10 ? '0' + h : h;
	m = m < 10 ? '0' + m : m;
	s = s < 10 ? '0' + s : s;

	document.title = h + ':' + m + ':' + s;
}, 1000);

 

发表评论