摘要:幾行js代碼即可實現title標題閃爍提示信息,不信你點開看看。
幾行js代碼即可實現title標題閃爍提示信息,不信你點開看看。
你看本網頁的標題,是不是在閃爍呀,哈哈,是不是很好玩。
其實代碼很簡單...
源碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS實現title標題閃爍提示信息</title> </head> <body> <script type="text/javascript"> _record = 0; var myTitle = document.title; function titleBlink(){ _record++; if(_record==3){//當變量_record累加到3是,將其賦值為1。相當于無限循環。 _record=1; } if(_record==1){ document.title='【 】'+myTitle; } if(_record==2){ document.title='【新消息】'+myTitle; } setTimeout("titleBlink()",500);//調節時間,單位毫秒。 } titleBlink(); </script> <center><h1>幾行js實現閃爍的title標題。</h1></center> <div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';"> </div> </body> </html>
網友評論:
45454
2017-03-09 20:01:24 回復
網友評論:
來看看
2016-12-29 19:08:55 回復