[求助] JS高手请进...问个JS冲突的问题..............
时间:2010-02-09
来源:互联网
JScript code
请问这2段JS一个是文字上翻公告的JS。一个是大图轮换的JS。每个页面单独用都没问题,但这2个效果放一个页面会起冲突(2个效果都不动了) 原因在哪呢?。我看不大懂。有朋友指点说修改起冲突的参数,可改哪里呢。请指教?不胜感激
var timer = null; var offset = 5000; var index = 0; //大图交替轮换 function slideImage(i){ var id = 'image_'+ target[i]; $('#'+ id) .animate({opacity: 1}, 800, function(){ $(this).find('.word').animate({height: 'show'}, 'slow'); }).show() .siblings(':visible') .find('.word').animate({height: 'hide'},'fast',function(){ $(this).parent().animate({opacity: 0}, 800).hide(); }); } //bind thumb a function hookThumb(){ $('#thumbs li a') .bind('click', function(){ if (timer) { clearTimeout(timer); } var id = this.id; index = getIndex(id.substr(6)); rechange(index); slideImage(index); timer = window.setTimeout(auto, offset); this.blur(); return false; }); } //bind next/prev img function hookBtn(){ $('#thumbs li img').filter('#play_prev,#play_next') .bind('click', function(){ if (timer){ clearTimeout(timer); } var id = this.id; if (id == 'play_prev') { index--; if (index < 0) index = 6; }else{ index++; if (index > 6) index = 0; } rechange(index); slideImage(index); timer = window.setTimeout(auto, offset); }); } //get index function getIndex(v){ for(var i=0; i < target.length; i++){ if (target[i] == v) return i; } } function rechange(loop){ var id = 'thumb_'+ target[loop]; $('#thumbs li a.current').removeClass('current'); $('#'+ id).addClass('current'); } function auto(){ index++; if (index > 6){ index = 0; } rechange(index); slideImage(index); timer = window.setTimeout(auto, offset); } $(function(){ //change opacity $('div.word').css({opacity: 0.85}); auto(); hookThumb(); hookBtn(); }); /*-----------------------------------------------------------------------------*/ function marquee(height,speed,delay){ var scrollT; var pause = false; var ScrollBox = document.getElementById("topadlink"); if(document.getElementById("holder").offsetHeight <= height) return; var _tmp = ScrollBox.innerHTML.replace('holder', 'holder2') ScrollBox.innerHTML += _tmp; ScrollBox.onmouseover = function(){pause = true} ScrollBox.onmouseout = function(){pause = false} ScrollBox.scrollTop = 0; function start(){ scrollT = setInterval(scrolling,speed); if(!pause) ScrollBox.scrollTop += 2; } function scrolling(){ if(ScrollBox.scrollTop % height != 0){ ScrollBox.scrollTop += 2; if(ScrollBox.scrollTop >= ScrollBox.scrollHeight/2) ScrollBox.scrollTop = 0; } else{ clearInterval(scrollT); setTimeout(start,delay); } } setTimeout(start,delay); } marquee(24,30,3000);
请问这2段JS一个是文字上翻公告的JS。一个是大图轮换的JS。每个页面单独用都没问题,但这2个效果放一个页面会起冲突(2个效果都不动了) 原因在哪呢?。我看不大懂。有朋友指点说修改起冲突的参数,可改哪里呢。请指教?不胜感激
作者: xnhlove 发布时间: 2010-02-09
2段JS外面 在分别套个 function(){}
看看
看看
作者: KK3K2005 发布时间: 2010-02-09
把你的页面在安有firebug的ff中运行看一看firebug给什么错误
作者: xiaofanku 发布时间: 2010-02-09
jquery调用啊,jsp了?
作者: qinde025 发布时间: 2010-02-09
引用 2 楼 xiaofanku 的回复:
把你的页面在安有firebug的ff中运行看一看firebug给什么错误
把你的页面在安有firebug的ff中运行看一看firebug给什么错误
同意,现在什么错误都不知道啊
作者: kingwolf_JavaScript 发布时间: 2010-02-09
你仔细找找看,外面页面应该有个var target的定义,把它copy到js里就行了
作者: dittoingz 发布时间: 2011-10-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28