哪位高手能帮忙指点下如何让下面的js兼容ie6浏览器呢?startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("navmall");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+="over";
}
node.onmouseout=function() {
this.className=this.className.replace("over", "");
}
node.onmouseover=function() {
this.className+="over";
this.getElementsByTagName("a")[0].style.backgroundColor="#736767";
this.getElementsByTagName("a")[0].style.color="#FFF";
}
node.onmouseout=function() {
this.className=this.className.replace("over", "");
this.getElementsByTagName("a")[0].style.backgroundColor="";
this.getElementsByTagName("a")[0].style.color="";
}}}}}
window.onload=startList;
if (document.all&&document.getElementById) {
navRoot = document.getElementById("navmall");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+="over";
}
node.onmouseout=function() {
this.className=this.className.replace("over", "");
}
node.onmouseover=function() {
this.className+="over";
this.getElementsByTagName("a")[0].style.backgroundColor="#736767";
this.getElementsByTagName("a")[0].style.color="#FFF";
}
node.onmouseout=function() {
this.className=this.className.replace("over", "");
this.getElementsByTagName("a")[0].style.backgroundColor="";
this.getElementsByTagName("a")[0].style.color="";
}}}}}
window.onload=startList;
解决方案 »
- 求大神指教,关于fullcalendar日历控件问题
- 100分求javascript正则表达式
- 求助 当点击button的时候全部的按钮为disabled灰色呢 用JS脚本怎么写
- 问一个简单的问题,有关在文本框中添加一段文字
- window.open()
- 解释代码 mn=objMmInfo[cActIdx].mmUrl;的意思
- 请问哪里有象新浪一样两边图片随位置一起动的代码啊
- 一个复选框的问题!很急!!帮帮忙!!!!
- 取得浏览器的版本的函数是什么?:(突然忘记了,就是想不起来)
- js扩展库不太明白的地方
- 求关闭当前页面的时候打开新页面的代码,要兼容哦
- 请问javascript是否可以处理用户输入的表格数据,将处理后的结果提交到服务器?
node = navRoot.childNodes[i];不要用childNodes 用 getElementsByTagName
window.onload = function(){
addEffect("indexbox");
addEffect("indexbox2");
addEffect("indexbox3");
addEffect("indexbox4");
addEffect("indexbox5");
addEffect("indexbox6");
addEffect("indexbox7");
addEffect("indexbox8");
addEffect("indexbox9");
addEffect("indexbox10");
addEffect("indexbox11");
addEffect("indexbox12");
addEffect("indexbox13");
addEffect("indexbox14");
}
/*** @param cn--要获取的class*/
function addEffect(cn){
var countArr = [];
var obj = getClass(document.body,cn);
for( var j=0;j<obj[0].getElementsByTagName("td").length;j++){
var liObj = obj[0].getElementsByTagName("td")[j];
countArr.push(liObj);
liObj.onmouseover = function(){
for(var k=0;k<countArr.length;k++){
startMove(countArr[k],{opacity:70});
}
startMove(this,{opacity:100});
}
liObj.onmouseout = function(){
for(var k=0;k<countArr.length;k++){
startMove(countArr[k],{opacity:100});
}
}
}
}
/*** 通过class获取对象*/
function getClass(oParent, sClass){
var aElem = oParent.getElementsByTagName('*');
var aClass = [];
var i = 0;
for(i=0;i<aElem.length;i++)if(aElem[i].className == sClass)aClass.push(aElem[i]);
return aClass;
}
/*** 动作类* 用法:* startMove(目标对象 ,目标属性(多个), 动作完成后执行(fun))*/
function startMove(target, object, onComplete){
if(target.timer)clearInterval(target.timer);
target.timer = setInterval(function (){
doMove(target, object, onComplete);
}, 30);
}
function getStyle(target, attr){
return target.currentStyle?target.currentStyle[attr]:getComputedStyle(target, false)[attr];
}
function doMove(target, object, onComplete){
var iCur = 0;
var attr = '';
var bStop = true;
for(attr in object){
attr == 'opacity' ? iCur = parseInt(parseFloat(getStyle(target, 'opacity'))*100) : iCur = parseInt(getStyle(target, attr));
if(isNaN(iCur))iCur = 0;
if(navigator.userAgent.indexOf("Firefox") > 0){
var iSpeed = (object[attr]-iCur) / 3;
}else{
var iSpeed = (object[attr]-iCur) / 3;
}
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
if(parseInt(object[attr])!=iCur)bStop = false;
if(attr=='opacity'){
target.style.filter = "alpha(opacity:"+(iCur+iSpeed)+")";
target.style.opacity = (iCur + iSpeed) / 100;
}else{
attr == 'zIndex' ? target.style[attr] = iCur + iSpeed : target.style[attr] = iCur + iSpeed +'px';
}
}
if(bStop){
clearInterval(target.timer);
target.timer = null;
if(onComplete)onComplete();
}
}
</script>