文字滚动的另一方法 拆分文字来做到文字滚动
生活随笔
收集整理的這篇文章主要介紹了
文字滚动的另一方法 拆分文字来做到文字滚动
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
最近在看javascript詳解這本書看到這個例子
文字滾動,拆分文字來做到文字滾動。
代碼如下
<!DOCTYPE html> <html> <head> <meta charset="gb2312" /> <title>專題</title> <style type="text/css"> body{color:#333;font:12px/20px arial; background:#FFF;} body,div,form,img,p,h1,h2,dl,dt,dd,ul,li{padding:0;margin:0;} ul,li{list-style:none;} em{font-style:normal;} img{display:block;border:0} a{color:#333;text-decoration:none} a:hover,td a:hover{color:#f60;text-decoration:underline} </style><script> var message = "學習javascript將讓你的網頁更精彩"; message += " 你準備好,學習javascript了嗎?"; var space = "..."; var position = 0; function scroller(){var newtext = message.substring(position,message.length)+space+message.substring(0,position);var con = document.getElementById("tabledata");con.firstChild.nodeValue = newtext;position++;if(position>message.length){position=0}var timer = window.setTimeout(scroller,200);con.onmouseover = function(){clearInterval(timer);}con.onmouseout = function(){timer = window.setTimeout(scroller,200);}}window.onload = function(){ scroller(); } </script> </head> <body><div id="tabledata">message goes here</div></body> </html>?
轉載于:https://www.cnblogs.com/jingangel/archive/2012/12/02/2798018.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的文字滚动的另一方法 拆分文字来做到文字滚动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: S3C6410移植u-boot-2010
- 下一篇: 网站的iphone版快开发完了