浏览器标题栏闪动

2013-8-13 liyangweb.com 李杨 JavaScript

当网页有新消息时,如何能引起用户的注意呢?

我们可以在浏览器的标题栏中来闪动提醒,这样即使当前页面在后台,用户也可以很只管的看到提示消息。

代码如下:

<meta charset="utf-8" />
<script type="text/javascript">
<!--
function BlinkTitle(title, timeout){
	var self = this;
	var timer = null;
	var backup = document.title;

	self.start = function(title, timeout){
		self.stop();

		if(title != undefined){
			self.title = title;
		}
		self.timeout = timeout == undefined? 600: timeout;

		function blink(){
			document.title = document.title == backup? self.title : backup;
		}
		blink();
		timer = setInterval(blink, self.timeout);
	}

	self.stop = function(){
		if(timer != null){
			document.title = backup;
			clearInterval(timer);
			timer = null;
		}
	}

	self.start(title, timeout);
}

var blink = new BlinkTitle('www.liyangweb.com');
//-->
</script>

<a onclick="blink.stop()">点此停止</a>

 

标签: JavaScript

评论:

grafiscar
约 22 小时前
<a href="http://www.avalonsoccer.com/mackage-kay-fur-trim-down-coat-mackager">mackage kay fur trim down coat</a> <a href="http://www.jemegaupload.com/silver-purple-womens-nike-air-max-2016-shoes-sneakere">silver purple womens nike air max 2016 shoes</a> <a href="http://www.plugginto.com/bon-march%C3%A9-under-armour-curry-3-femmes-rose-footc">bon march茅 under armour curry 3 femmes rose</a> <a href="http://www.incommonblog.com/nike-air-max-1-blue-and-white-skox">nike air max 1 blue and white</a> <a href="http://www.uheita.com/nike-free-run-5.0-sizing-sportsd">nike free run 5.0 sizing</a> <a href="http://www.headmull.com/peacock-coach-wallet-coachr">peacock coach wallet</a>
[url=http://www.grafiscar.com/]grafiscar[/url]
www
2013-08-13 20:36
靠有广告了;牛逼
liyangweb.com 李杨
2013-08-13 20:45
@www:(*^__^*)域名钱不知道猴年马月才能赚回来~~~

发表评论:

Powered by emlog 冀ICP备13011830号-1