请教JS冲突的问题 javascriptjquery 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 firefox或者chorme里打开网页按ctrl+shift+i,看看报什么错。没有html调不起来 var $ = function (id) { return document.getElementById(id); }就是这段覆盖了jquery的工厂函数,解决办法有2个,1. 把这块的换个名字。var foucsbox = function (time) { var time = time || 3500 , bigimgs = big.getElementsByTagName('li') , samllimgs = samll.getElementsByTagName('li') , imglink = tip.getElementsByTagName('a')[0] , slide = function (z) { samllimgs[lastIndex].className = ''; samllimgs[z].className = 'current'; bigimgs[lastIndex].style.display = 'none'; bigimgs[z].style.display = 'block'; try { imglink.innerHTML = samllimgs[z].getElementsByTagName('img')[0].alt; } catch (e) { imglink.innerText = samllimgs[z].firstChild.firstChild.alt; } lastIndex = i = z; } , helper = function (z) { return function (e) { var na; if (!e) { e = window.event; na = e.srcElement.nodeName; } else { na = e.target.nodeName; } if (na === 'IMG') { slide(z); } } } , lastIndex = i = 0, x, y = bigimgs.length , getPrevI = function (q) { return i - q < 0 ? y - q : i - 1; } , getNextI = function (q) { return i + q >= y ? i + q - y : i + 1; } try { imglink.innerText = samllimgs[0].getElementsByTagName('img')[0].alt; } catch (e) { imglink.innerText = samllimgs[0].firstChild.firstChild.alt; } for (x = 1; x < y; x += 1) { bigimgs[x].style.display = 'none'; } for (x = 0; x < y; x += 1) { samllimgs[x].onmouseover = helper(x); } topCon.children[2].onclick = function (e) { i = lastIndex; var t; if (!e) { e = window.event; t = e.srcElement; } else { t = e.target; } switch (t.className) { case 'icon_prev': slide(getPrevI(1)); break; case 'icon_next': slide(getNextI(1)); break; } }; topCon.onmouseover = function () { clearInterval(s); }; topCon.onmouseout = function () { s = setInterval(function () { slide(i); i = getNextI(1); }, time); };};var byId = function (id) { return document.getElementById(id); } , topCon = byId('flower1') , big = byId('focus_pic1') , samll = byId('focus_list1') , tip = byId('focus_title1')foucsbox(2500);var topCon = byId('flower2') , big = byId('focus_pic2') , samll = byId('focus_list2') , tip = byId('focus_title2')foucsbox(2500);var topCon = byId('flower3') , big = byId('focus_pic3') , samll = byId('focus_list3') , tip = byId('focus_title3')foucsbox(2500);var topCon = byId('flower4') , big = byId('focus_pic4') , samll = byId('focus_list4') , tip = byId('focus_title4')foucsbox(2500);解决办法2,由于js的变量作用域或作用范围是按函数来划分界限的,所以放在一个函数里边,把他执行一下。一般通俗的叫:立即执行函数。这样,这个内部$不会穿透,或影响到外边去。这是一种偷懒或省力的解决办法。但是这个方法的缺点是:要求的技术储备比较高,里边也有少量的坑。比如,即不让$穿透,还需要把里边的方法暴露给外边。这时候需要借助window,把方法绑定在window上面去。比如:window.method = method.(function(window){ var $ = function(id) { return document.getElementById(id); }, topCon = $('flower1'), big = $('focus_pic1'), samll = $('focus_list1'), tip = $('focus_title1'); foucsbox(2500); var topCon = $('flower2'), big = $('focus_pic2'), samll = $('focus_list2'), tip = $('focus_title2'); foucsbox(2500); var topCon = $('flower3'), big = $('focus_pic3'), samll = $('focus_list3'), tip = $('focus_title3'); foucsbox(2500); var topCon = $('flower4'), big = $('focus_pic4'), samll = $('focus_list4'), tip = $('focus_title4'); foucsbox(2500);}(window)) 写了一个公用脚本,通过网上的在线压缩后,晕错误 jquery新手问题 easyui的图标问题 一个关于表格的笨笨问题 在线等~~~~~~~~~~ 当点击下拉列表框某一选项,立即返回selectedindex值,怎样实现?急求 100分 如何让光标在敲回车时跳到下一个Text框 用JavaScript连接数据库的问题,在线等待 能不能在打开网页的时候让他运行网站里的bat文件 ueditor上传图片的问题 如何获取Firefox浏览器中input类型为file的上传的绝对路径? js能够把文本段依据标点符号分成一句句的吗
没有html调不起来
就是这段覆盖了jquery的工厂函数,解决办法有2个,
1. 把这块的换个名字。var foucsbox = function (time) {
var time = time || 3500
, bigimgs = big.getElementsByTagName('li')
, samllimgs = samll.getElementsByTagName('li')
, imglink = tip.getElementsByTagName('a')[0]
, slide = function (z) {
samllimgs[lastIndex].className = '';
samllimgs[z].className = 'current';
bigimgs[lastIndex].style.display = 'none';
bigimgs[z].style.display = 'block';
try {
imglink.innerHTML = samllimgs[z].getElementsByTagName('img')[0].alt;
}
catch (e) {
imglink.innerText = samllimgs[z].firstChild.firstChild.alt;
}
lastIndex = i = z;
}
, helper = function (z) {
return function (e) {
var na;
if (!e) {
e = window.event;
na = e.srcElement.nodeName;
}
else {
na = e.target.nodeName;
}
if (na === 'IMG') {
slide(z);
}
}
}
, lastIndex = i = 0, x, y = bigimgs.length
, getPrevI = function (q) { return i - q < 0 ? y - q : i - 1; }
, getNextI = function (q) { return i + q >= y ? i + q - y : i + 1; }
try {
imglink.innerText = samllimgs[0].getElementsByTagName('img')[0].alt;
}
catch (e) {
imglink.innerText = samllimgs[0].firstChild.firstChild.alt;
}
for (x = 1; x < y; x += 1) {
bigimgs[x].style.display = 'none';
}
for (x = 0; x < y; x += 1) {
samllimgs[x].onmouseover = helper(x);
}
topCon.children[2].onclick = function (e) {
i = lastIndex;
var t;
if (!e) {
e = window.event;
t = e.srcElement;
} else {
t = e.target;
}
switch (t.className) {
case 'icon_prev':
slide(getPrevI(1));
break;
case 'icon_next':
slide(getNextI(1));
break;
}
};
topCon.onmouseover = function () {
clearInterval(s);
};
topCon.onmouseout = function () {
s = setInterval(function () {
slide(i);
i = getNextI(1);
}, time);
};
};var byId = function (id) { return document.getElementById(id); }
, topCon = byId('flower1')
, big = byId('focus_pic1')
, samll = byId('focus_list1')
, tip = byId('focus_title1')
foucsbox(2500);var topCon = byId('flower2')
, big = byId('focus_pic2')
, samll = byId('focus_list2')
, tip = byId('focus_title2')
foucsbox(2500);var topCon = byId('flower3')
, big = byId('focus_pic3')
, samll = byId('focus_list3')
, tip = byId('focus_title3')
foucsbox(2500);var topCon = byId('flower4')
, big = byId('focus_pic4')
, samll = byId('focus_list4')
, tip = byId('focus_title4')
foucsbox(2500);解决办法2,由于js的变量作用域或作用范围是按函数来划分界限的,所以放在一个函数里边,把他执行一下。一般通俗的叫:立即执行函数。这样,这个内部$不会穿透,或影响到外边去。这是一种偷懒或省力的解决办法。但是这个方法的缺点是:要求的技术储备比较高,里边也有少量的坑。比如,即不让$穿透,还需要把里边的方法暴露给外边。这时候需要借助window,把方法绑定在window上面去。比如:window.method = method.(function(window){
var $ = function(id) {
return document.getElementById(id);
},
topCon = $('flower1'),
big = $('focus_pic1'),
samll = $('focus_list1'),
tip = $('focus_title1');
foucsbox(2500); var topCon = $('flower2'),
big = $('focus_pic2'),
samll = $('focus_list2'),
tip = $('focus_title2');
foucsbox(2500); var topCon = $('flower3'),
big = $('focus_pic3'),
samll = $('focus_list3'),
tip = $('focus_title3');
foucsbox(2500); var topCon = $('flower4'),
big = $('focus_pic4'),
samll = $('focus_list4'),
tip = $('focus_title4');
foucsbox(2500);
}(window))