javaScript滾動新聞,滾動新聞

來源:互聯網
上載者:User

javaScript滾動新聞,滾動新聞

<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>滾動新聞</title></head><style type="text/css">#div1{width:200px;height:80px; background-color:#CCC; position:absolute; left:0px; top:0px; z-index:1;overflow:hidden;}#imgs{width:100px; height:400px; background-color:#9C9; position:absolute; left:200px; top:0px; z-index:1;//垂直方向置於最頂層overflow:hidden;//超出部分隱藏}</style><body><!--div 的高度設定比實際需要的高度小--><div id="div1">    <ul id="news">    <li><a href="#">aaaaaaaaaaaaaaa</a></li>        <li><a href="#">bbbbbbbbbbbbbbb</a></li>        <li><a href="#">ccccccccccccccc</a></li>        <li><a href="#">ddddddddddddddd</a></li>        <li><a href="#">eeeeeeeeeeeeeee</a></li>        <li><a href="#">fffffffffffffff</a></li>        <li><a href="#">ggggggggggggggg</a></li>        </ul>    </div>    <div id="imgs">    <img src="imgs/11.png"></img>        <img src="imgs/22.png"></img>        <img src="imgs/33.png"></img>        <img src="imgs/44.png"></img>        <img src="imgs/55.png"></img>    </div></body></html><script type="text/javascript" language="javascript">//注意需要讓當前的dom載入完全之後,再執行js代碼//文字滾動news = document.getElementById('news');function newScroll(node){var t = node.firstChild;node.removeChild(t);node.appendChild(t);}id = setInterval('newScroll(news)',400);news.onmouseover = function(){clearTimeout(id);}news.onmouseout = function(){id = window.setInterval('newScroll(news)',400);}//圖片滾動imgs = document.getElementById('imgs');id1 = setInterval('newScroll(imgs)',400);imgs.onmouseover = function(){clearTimeout(id1);}imgs.onmouseout = function(){id1 = window.setInterval('newScroll(imgs)',400);}</script>


怎利用javascript指令碼加入滾動新聞的連結?那在html中怎更改原始碼?

還是用marquee簡單

<marquee scrollamount='2' scrolldelay='220' direction= 'left' width='148' id=xx height='20' onmouseover=this.stop() onmouseout=this.start()>
aaaaaaaaaaaaaaaaa bbbbbbbbbbbbbb
</marquee>
 
一段對於新聞逐行滾動的JavaScript代碼問題

上控製版面上找
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.