电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> Javascript>>js代码:一出现便开始滚屏:

js代码:一出现便开始滚屏

来源:网络 | 2007-1-6 | (有2640人读过)

首页iframe的代码:
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
</HEAD><FRAMESET border=0
frameBorder=0 frameSpacing=0 rows=0,170,*><FRAME frameBorder=0 marginHeight=0
marginWidth=0 name=top noResize scrolling=no src="about:blank"><FRAME
frameBorder=0 marginHeight=0 marginWidth=0 name=main noResize scrolling=no
src="图片内容页路径"><FRAME frameBorder=0 marginHeight=0
marginWidth=0 name=code noResize scrolling=no
src="滚动代码页路径"></FRAMESET><noframes></noframes></HTML>

滚动代码页路径中对应的页面代码:

<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<SCRIPT language=JavaScript>
<!--//
 var x = 0;
 var y = 0;
 var limdex = 400;
 var dest = 0;
 var distance = 0;
 var step = 0;
 var destination = 0;
 var on = true;

function scrollit(destination) {
 step = 2;
 dest = destination;
 if (x<dest & x < limdex){
  while (x<dest) {
   step += (step / 7);
   x += step;
   parent.frames[1].scroll(x,0);
  } 
                        // top.main.scroll(dest,0);
  if(dest <=limdex) { parent.frames[1].scroll(dest,0); }
  x = dest;
 }
 if (x > dest)  {
  while (x>dest) {
   step += (step / 7);
   if(x >= (0+step)) { x -= step; parent.frames[1].scroll(x,0); }
   else break;
  }
  if(dest >= 0) { parent.frames[1].scroll(dest,0); }
  x = dest;
 }
 if (x<1) { parent.frames[1].scroll(1,0); x=1 }
 if (x>limdex) { parent.frames[1].scroll(limdex,0); x=limdex }
 x = dest;
}

function scrollnow() {
                if (on){
                if (x < limdex & x >= 0 ) {             
                                parent.frames[1].scroll(x,0);
                           
                        x = x + 1;
                       
                        setTimeout('scrollnow()', 32);
       
                }
                else if (x < 0) {
               
                        x = limdex;
                        scrollnow();
                }
            else {
               
                x=0;
                scrollnow();
                }
                }

}

// *********************************
// 去掉原来的stopscroll()
function stopscroll() {
        if (on){
        on = false;
        }
        else {
        on = true;
        scrollnow();
        }
       
}
function startscroll() { on = true; scrollnow();}
function stop_start() {
 if (on){ on = false;}else { on = true;scrollnow();}
}
//***********************************

//-->
</SCRIPT>

<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 onload=scrollnow() topMargin=0
marginwidth="0" marginheight="0"></BODY></HTML>


(www.cncfan.com整理)
Javascript热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号