⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7-10.htm

📁 JScript网页特效,包含很多的实现网页特效的方法.
💻 HTM
字号:
<html>
<head>
<title>§7.10 类似一种广告切换的效果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF">

<script language=JavaScript> 
var scrollerwidth=180        //可移动的层的宽度,设为图片的宽度
var scrollerheight=135       //可移动的层的高度,设为图片的高度
var scrollerbgcolor='white'  //层的背景色
var pausebetweenimages=3000  //图片切换的速度
var slideimages=new Array()  //用于存储要切换的图片的数组
slideimages[0]='<img src="img01.jpg">'
slideimages[1]='<img src="img02.jpg">'
slideimages[2]='<img src="img03.jpg">'

if (slideimages.length>1)
  i=2
else
  i=0
if (document.all)
{ 
  document.writeln('<center><span id="main" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+'">') 
  document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">') 
  document.writeln('<div id="first" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">') 
  document.write(slideimages[0]) 
  document.writeln('</div>') 
  document.writeln('<div id="second" style="position:absolute;width:'+scrollerwidth+';left:0;top:0">') 
  document.write(slideimages[1]) 
  document.writeln('</div>') 
  document.writeln('</div>') 
  document.writeln('</span>') 
} 
  
</script>

<script language=JavaScript>
function scroll1(whichdiv)
{
  tdiv=eval(whichdiv)
  if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5)
  {
    tdiv.style.pixelTop=0
    setTimeout("scroll1(tdiv)",pausebetweenimages)
    setTimeout("scroll2(second)",pausebetweenimages)
    return
  }
  if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1)
  {
    tdiv.style.pixelTop-=5
    setTimeout("scroll1(tdiv)",100)
  }
  else
  {
    tdiv.style.pixelTop=scrollerheight
    tdiv.innerHTML=slideimages[i]
    if (i==slideimages.length-1)
      i=0
    else
      i++
  }
}

function scroll2(whichdiv)
{
  tdiv2=eval(whichdiv)
  if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5)
  {
    tdiv2.style.pixelTop=0
    setTimeout("scroll2(tdiv2)",pausebetweenimages)
    setTimeout("scroll1(first)",pausebetweenimages)
    return
  }
  if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1)
  {
    tdiv2.style.pixelTop-=5
    setTimeout("scroll2(second)",100)
  }
  else
  {
    tdiv2.style.pixelTop=scrollerheight
    tdiv2.innerHTML=slideimages[i]
    if (i==slideimages.length-1)
      i=0
    else
      i++
  }
}

function startscroll()
{
  if (document.all)
  {
    second.style.top=scrollerheight
    scroll1(first)
  }
}

window.onload=startscroll

</script>


</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -