js 通知

轉自 : https://huhanlin-2008-163-com.iteye.com/blog/772506

  1. <script type="text/javascript" language="Javascript">  
  2. var scrlSpeed=1  
  3. // decreasing speed for mozilla  
  4. scrlSpeed=(document.all)? scrlSpeed : Math.max(1, scrlSpeed-1)  
  5. function initScroll(container,object){  
  6.     if (document.getElementById(container) != null){  
  7.         var contObj=document.getElementById(container);  
  8.         var obj=document.getElementById(object);  
  9.         contObj.style.visibility = "visible";  
  10.         contObj.scrlSpeed = scrlSpeed;  
  11.         widthContainer = contObj.offsetWidth;  
  12.         obj.style.left=parseInt(widthContainer)+"px";  
  13.         widthObject=obj.offsetWidth;  
  14.         interval=setInterval("objScroll('"+ container +"','"+ object +"',"+ widthContainer +")",20);  
  15.         contObj.onmouseover = function(){  
  16.             contObj.scrlSpeed=0;  
  17.         }  
  18.         contObj.onmouseout = function(){  
  19.             contObj.scrlSpeed=scrlSpeed;  
  20.         }   
  21.     }  
  22. }  
  23.   
  24. function objScroll(container,object,widthContainer){  
  25.     var contObj=document.getElementById(container);  
  26.     var obj=document.getElementById(object);  
  27.     widthObject=obj.offsetWidth;  
  28.     if (parseInt(obj.style.left)>(widthObject*(-1))){  
  29.         obj.style.left=parseInt(obj.style.left)-contObj.scrlSpeed+"px";  
  30.     } else {  
  31.         obj.style.left=parseInt(widthContainer)+"px";  
  32.     }  
  33. }  
  34.   
  35.    
  36.   
  37. // on page load we initiate scrolling  
  38. window.onload=function(){   
  39.     initScroll("scrlContainer", "scrlContent");  
  40. }  
  41.   
  42. </script>  



2.css 

Java代碼 

 收藏代碼

  1. <style type="text/css">  
  2. body{  
  3.     margin:0;  
  4.     padding:0;  
  5.     background:#fff;  
  6.     font: 70% Arial, Helvetica, sans-serif;  
  7. }  
  8. #scrlContainer{  
  9.     visibility:hidden;  
  10.     background:#f1f1f1;  
  11.     position:relative;  
  12.     overflow:hidden;  
  13.     width:250px;  
  14.     height:20px;  
  15.     line-height:20px;  
  16.     margin:1em;  
  17. }  
  18.   
  19. #scrlContent{  
  20.     position:absolute;  
  21.     left:0;  
  22.     top:0;  
  23.     white-space:nowrap;  
  24. }  
  25. </style>  



3.html 

Java代碼 

 收藏代碼

  1. <html>   
  2. <body>  
  3. <div id="scrlContainer">  
  4.     <div id="scrlContent">Some very, very useful information will  
  5. appear here, yet it will move around your screen so it will be hard to  
  6. read it. But the client wants it, so here it is. </div>  
  7. </div>                
  8. </body>  
  9. </html>   
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章