用两个div嵌套链接文字,最外面的div设置 overflow:hidden,并用js动态控制它的width,实现伸展与收缩。
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
新闻轮显的demo <script> <BR>var handle; <BR>var handle2; <BR>var boxW=0; <BR>var titleNum=0; <BR>function init(){ <BR> var newsTitles = "快乐笛子的博客|中央统战部:新社会阶层纳入中国统一战线|中俄明年将在俄远东地区举行联合反恐演|广州宾馆3小时内须将旅客信息传给公安机关|国亲将推动弹劾陈水扁案"; <BR> var newsLinks = "http://www.happyshow.org|http://news.sina.com.cn/c/2006-09-02/093410901015.shtml|http://news.sina.com.cn/c/2006-09-02/02069914065s.shtml|http://news.sina.com.cn/c/2006-09-02/043210898986.shtml|http://news.sina.com.cn/c/2006-09-02/06069915455s.shtml"; <BR> document.getElementById("box").style.width = "400px"; <BR> document.getElementById("title").innerHTML = "<a target='_blank' href='"+newsLinks.split("|")[titleNum]+"'>"+newsTitles.split("|")[titleNum]+""; <BR> //setTimeout("decreaseBoxW();",1500); <BR> titleNum++; <BR> setInterval("innerTitle('"+newsTitles+"','"+newsLinks+"')",3100); <BR>} <BR>function innerTitle(titles,links){ <BR> var t = titles.split("|"); <BR> var a = links.split("|"); <BR> if (!t[titleNum]) <BR> titleNum=0; <BR> document.getElementById("box").style.width = "0px"; <BR> document.getElementById("title").innerHTML = "<a target='_blank' href='"+a[titleNum]+"'>"+t[titleNum]+""; <BR> handle2 = setInterval("increaseBoxW()",1);//展开 <BR> titleNum++; <BR>} <BR>function increaseBoxW(){ <BR> boxW = parseInt(document.getElementById("box").style.width); <BR> boxW = boxW + 4; <BR> if (boxW>400){ <BR> clearInterval(handle2); <BR> document.getElementById("box").style.width = "400px"; <BR> setTimeout("decreaseBoxW()",1500) <BR> }else{ <BR> document.getElementById("box").style.width = boxW+"px"; <BR> } <BR>} <BR>function decreaseBoxW(){ <BR> handle = setInterval("decreaseBoxW2()",4) <BR>} <BR>function decreaseBoxW2(){ <BR> boxW = parseInt(document.getElementById("box").style.width); <BR> boxW = boxW - 16; <BR> if(boxW<0){ <BR> clearInterval(handle); <BR> document.getElementById("box").style.width = "0px"; <BR> }else{ <BR> document.getElementById("box").style.width = boxW + "px"; <BR> } <BR>} <BR></script>
<script> <BR>init(); <BR></script>
Déclaration:Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn