连续滚动的超级链接文字网页代码


向上滚动

<div id=”marquees”>
<a href=”#”>网页教学网一</a><br>
<br>
<a href=”#”>网页教学网二</a><br>
<br>
<a href=”#”>网页教学网三</a><br>
<br>
<a href=”#”>网页教学网四</a>
<br>
</div>
<script language=”JavaScript”>

marqueesHeight=200;
stopscroll=false;

with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX=”visible”;
style.overflowY=”hidden”;
noWrap=true;
onmouseover=new Function(”stopscroll=true”);
onmouseout=new Function(”stopscroll=false”);
}
document.write(’<div id=”templayer” style=”position:absolute;z-index:1;visibility:hidden”></div>’);

preTop=0; currentTop=0;

function init(){
templayer.innerHTML=””;
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval(”scrollUp()”,10);
}
document.body.onload=init;

function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>

向下滚动

<div id=”marquees”> <a href=”#”>网页教学网一</a><br>
<br>
<a href=”#”>网页教学网二</a><br>
<br>
<a href=”#”>网页教学网三</a><br>
<br>
<a href=”#”>网页教学网四</a><br>
<br>
</div>
<script language=”JavaScript”>

marqueesHeight=200;

with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX=”visible”;
style.overflowY=”hidden”;
noWrap=true;
onmouseover=new Function(”stopscroll=true”);
onmouseout=new Function(”stopscroll=false”);
}
document.write(’<div id=”templayer” style=”position:absolute;z-index:1;visibility:hidden”></div>’);
preTop=0; currentTop=0;getlimit=0;stopscroll=false;

function init(){
templayer.innerHTML=””;
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML+=templayer.innerHTML;
setInterval(”scrollDown()”,10);
}init();

function scrollDown(){
if(stopscroll==true) return;

preTop=marquees.scrollTop;
marquees.scrollTop-=1;
if(preTop==marquees.scrollTop){
if(!getlimit){
marquees.scrollTop=templayer.offsetHeight*2;
getlimit=marquees.scrollTop;
}
marquees.scrollTop=getlimit-templayer.offsetHeight+marqueesHeight;
marquees.scrollTop-=1;
}
}
</script>

向左滚动

<div id=”marquees”>
<a href=”#”>网页教学网一</a>
<a href=”#”>网页教学网二</a>
<a href=”#”>网页教学网三</a>
<a href=”#”>网页教学网四</a>
</div>

<div id=”templayer” style=”position:absolute;left:0;top:0;visibility:hidden”></div>
<script language=”JavaScript”>

marqueesWidth=200;

with(marquees){
style.height=0;
style.width=marqueesWidth;
style.overflowX=”hidden”;
style.overflowY=”visible”;
noWrap=true;
onmouseover=new Function(”stopscroll=true”);
onmouseout=new Function(”stopscroll=false”);
}
preLeft=0; currentLeft=0; stopscroll=false;

function init(){
templayer.innerHTML=””;
while(templayer.offsetWidth<marqueesWidth){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML+=templayer.innerHTML;
setInterval(”scrollLeft()”,10);
}init();

function scrollLeft(){
if(stopscroll==true) return;
preLeft=marquees.scrollLeft;
marquees.scrollLeft+=1;
if(preLeft==marquees.scrollLeft){
marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
}
}
</script>

向右滚动

<div id=”marquees”>
<a href=”#”>网页教学网一</a>
<a href=”#”>网页教学网二</a>
<a href=”#”>网页教学网三</a>
<a href=”#”>网页教学网四</a>
</div>
<div id=”templayer” style=”position:absolute;left:0;top:0;visibility:hidden”></div>
<script language=”JavaScript”>

marqueesWidth=200;

with(marquees){
style.height=0;
style.width=marqueesWidth;
style.overflowX=”hidden”;
style.overflowY=”visible”;
noWrap=true;
onmouseover=new Function(”stopscroll=true”);
onmouseout=new Function(”stopscroll=false”);
}
preTop=0; currentTop=0; getlimit=0; stopscroll=false;

function init(){
templayer.innerHTML=””;
while(templayer.offsetWidth<marqueesWidth){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML+=templayer.innerHTML;
setInterval(”scrollRight()”,10);
}init();

function scrollRight(){
if(stopscroll==true) return;

preLeft=marquees.scrollLeft;
marquees.scrollLeft-=1;
if(preLeft==marquees.scrollLeft){
if(!getlimit){
marquees.scrollLeft=templayer.offsetWidth*2;
getlimit=marquees.scrollLeft;
}
marquees.scrollLeft=getlimit-templayer.offsetWidth+marqueesWidth;
marquees.scrollLeft-=1;
}
}
</script>



相关阅读:
为你的网站增加亮点的9款jQuery插件推荐
linux ssh 升级安装方法
Oracle基础:bean的属性类型
JS.Class - 2. Methods & Types
设计视图中允许的九种数据类型
一直都需要的复制到系统剪贴板之IE,firefox兼容版
JavaServer Page(JSP)简介
数据字典表Truncate掉将导致数据库不可用
javascript asp教程 日期相关
Javascript 模式实例 观察者模式
JavaScript面向对象的两种书写方法以及差别
ACCESS数据库向MySQL快速迁移小程序(一)
Linux fgetcsv取得的数组元素为空字符串的解决方法
IE7,IE8 BUG导致CSS下载二次的解决方法
快速导航

Copyright © 2016 phpStudy |