JS无缝滚屏效果

下面的JS代码另存为一个外部的JS文件里,在使用时,先引用该JS文件,再滚屏的HTML后添加JS脚本,声明一个JS滚屏对象就可以使用了

可实现上下左右四个方向不同的滚动效果 数据挖掘交友

如另外为marquee.js

数据挖掘研究院

<script language="javascript" src="marquee.js"></script>
<div id="dv_Marquee">
  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th scope="col"><img src="demo.jpg" width="400" height="200" /></th>
    </tr>
    <tr>
      <td><img src="demo.jpg" width="400" height="200" /></td>
    </tr>
  </table>
</div>
<script language="javascript">
    var _m = new Marquee("_m","dv_Marquee","up",1,1);//向上滚屏

数据挖掘实验室


</script>

dv_Marquee是一个定义了宽高,无填充,无边框,溢出设置为隐藏的一个块区域,无需要额外的marquee标记 数据挖掘交友

如果横向滚动时,内容的实际宽度小于滚动区域宽度时,无滚动效果
纵向滚动与横向滚动一样

可实现四个方向的滚动方式 数据挖掘工具

鼠标移上去,自动停止

鼠标移开,恢复滚动

数据挖掘实验室

数据挖掘论坛

//以下代码存储为外部JS文件

//JS模拟Marquee连续滚屏效果
//IE 6.0 测试通过
//FireFox 1.5.0.7 测试通过
//Opera 9.02 测试通过
//NetScape 8.1测试通过

//author:梦猫猫
//QQ:16991200
//Created:2006-10-18
//intro:
/*
  instance:创建的实例名称
  marquee:滚动区域容器的ID,要求无填充,无边框,overflow为hidden
  direction:滚动方向,值分别为:up,down,left,right
  delay:滚动的速度,值最小为1,值越小越快
  amount:滚动步进量,值最小为1,值越大越快
*/
数据挖掘实验室

 function Marquee(instance,marquee,direction,delay,amount){
  this.instance =instance;//实例名称
  this.marquee = document.getElementById(marquee);
  this.delay = delay;
  if(this.delay==null){
   this.delay = 1;
  }
  this.amount = amount;
  if(this.amount==null){
   this.amount = 1;
  }
  this.direction = direction;
  this.width = this.marquee.clientWidth;
  this.height = this.marquee.clientHeight;
  this.container = document.createElement("table");
  this.container.border=0;
  this.container.cellspacing="0"
  this.container.cellpadding="0"
  var _HTML = this.marquee.innerHTML;
  this.marquee.innerHTML = "";
  this.marquee.appendChild(this.container);
  var _tr = this.container.insertRow(this.container.rows.length); 数据挖掘论坛
  var _td = _tr.insertCell(_tr.cells.length);
  _td.innerHTML = _HTML;
  this.scrollHeight = this.container.clientHeight;
  this.scrollWidth = this.container.clientWidth;
  switch(this.direction.toLowerCase()){
   case "up":
   case "down":
    if(this.scrollHeight>=this.height){
     var _tr = this.container.insertRow(this.container.rows.length);
     var _td = _tr.insertCell(_tr.cells.length);
     _td.innerHTML = _HTML;
     this.scrollHeight = this.container.clientHeight;
    }
    if(this.direction.toLowerCase()=="down"){
     this.marquee.scrollTop=this.scrollHeight/2;
    }
    break;
   default: 数据挖掘工具
    if(this.scrollWidth>=this.width){
     var _td = _tr.insertCell(_tr.cells.length);
     _td.innerHTML = _HTML;
     this.scrollWidth = this.container.clientWidth;
    }
    
  }
  
  this.marquee.m = this;
  
  this.intervalId = null;
  this.marquee.onmouseover = function (){
   this.m.Stop();
  }
  this.marquee.onmouseout = function (){
   this.m.Start();
  }
  this.Start();
 }
 Marquee.prototype.Start = function (){
  this.intervalId = setInterval(this.instance+".Scroll()",this.delay)
  //this.Scroll();
 }
 Marquee.prototype.Stop = function (sender){
  if(this.intervalId!=null){ 数据挖掘工具
   clearInterval(this.intervalId);
  }
 }
 Marquee.prototype.Scroll = function (){
  switch(this.direction.toLowerCase()){
   case "up":
    if((this.marquee.scrollTop+this.height)>=this.scrollHeight){
     this.marquee.scrollTop-=this.scrollHeight/2
    }
    if(this.scrollHeight>this.height){
     this.marquee.scrollTop+=this.amount;
    }
    break;
   case "down":
    if(this.marquee.scrollTop<=0){
     this.marquee.scrollTop+=this.scrollHeight/2
    }
    if(this.scrollHeight>this.height){
     this.marquee.scrollTop-=this.amount;
    }


    break;
   case "right":
    if(this.marquee.scrollLeft<=0){
     this.marquee.scrollLeft+=this.scrollWidth/2
    }
    if(this.scrollWidth>this.width){
     this.marquee.scrollLeft-=this.amount;
    }
    break;
   default:
    if((this.marquee.scrollLeft+this.width)>=this.scrollWidth){
     this.marquee.scrollLeft-=this.scrollWidth/2
    }
    if(this.scrollWidth>this.width){
     this.marquee.scrollLeft+=this.amount;
    }
  }
 }
//以上为外部JS代码

数据挖掘交友

[数据挖掘专家] [数据挖掘研究院] [数据挖掘论坛] [数据挖掘实验室]
上一篇:用DW文件库更新网站
下一篇:用FrontPage 2003发布您的网站
最新评论共有 0 位网友发表了评论 , 查看所有评论
发表评论( 不能超过250字,需审核,请自觉遵守互联网相关政策法规。 )
匿名?
数据挖掘网站导航 数据挖掘论坛导航
  • 数据挖掘工具
  • 数据挖掘论坛
  • DataCruncher - Cognos
  • MineSet - MathSoft
  • Intelligent Miner - GainSmarts
  • Sqlserver - SAS - Clementine
  • CART - Weka - WizSoft
  • NeuroShell - ModelQuest
  • data mining tools - Darwin
  • 数据挖掘交友
  • 数据挖掘博客
  • 数据挖掘工具
  • 数据挖掘资源
  • 数据挖掘技术算法
  • 数据挖掘相关期刊、会议
  • 研究院联盟合作专区
  • 数据挖掘基础与相关技术
  • 数据挖掘厂商与就业
  • 数据挖掘研究者乐园
  • 知名厂商数据挖掘工具资料
  • 国内数据挖掘实验室
  • Foreign Data Mining Lab
  • 热点关注
  • 网页javascript精华代码集
  • Javascript高级教程-神奇的字符串处理
  • Javascript高级教程-分割方法(splitting me
  • JS+CSS打造可拖动的聊天窗口层
  • javaScript对象和属性
  • 用FrontPage2003轻松制作ASP动态网页
  • JavaScript高级教程 - 子字符串
  • Javascript高级教程-介绍cookie
  • Javascript高级教程
  • JS无缝滚屏效果
  • 论坛最新话题
  • Foundations of Statistical Natural Langu
  • Game Theory meet Data Mining: A Recent P
  • System Building: How does it help or hin
  • 数据挖掘与Clementine培训
  • 新手报到
  • 求 SASEM 客户流失预测分析
  • 数据挖掘工程师/搜索研究院—北京——无线
  • 数据挖掘入门介绍(如何着手数据挖掘)
  • Information Overload Survey Results
  • The INEX 2005 Workshop on Element Retrie
  • 相关资讯
  • JavaScript高级教程 - 相关数组
  • Javascript高级教程-分割方法(splitting me
  • JavaScript高级教程 - 子字符串
  • Javascript高级教程-神奇的字符串处理
  • JavaScript高级教程 - 变量的使用方法
  • JavaScript高级教程 - 什么是变量
  • 一个if-then-else的快捷方式
  • Javascript高级教程-本教程的课程计划
  • Javascript高级教程
  • Javascript高级教程-介绍cookie
  • 数据挖掘实验室资料
  • 数据挖掘博客地址
  • 数据挖掘实验室网站地址
  • Prepare for Medicare audits by using dat
  • 注册成为SAS用户与爱好者俱乐部会员
  • 水南梅
  • 明日烟
  • 新人报道
  • 下载
  • 厦门服务器托管,450元/月—0592-5177319 高
  • 买空间送域名--0592-5177319 高静