浏览器兼容代码
window.onload=function(){
var div =document.getElementById('div1');
var cssnew=document.styleSheets[0].cssRules || document.styleSheets[0].rules || window.CSSRule.STYLE_RULE;
var t =null;
function time(speed,target){
clearInterval(t);
t=setInterval(function(){
if(div.offsetLeft==target){
clearInterval(t);
}else{
cssnew[1].style.left=div.offsetLeft+speed+'px';
}
},30)
//cssnew[1].style.width=30+"px";
}
div.onmouseover =function(){
time(10,0)
};
div.onmouseout=function(){
time(-10,-200)
};
}
ie7 和火狐不会报错 360浏览器回报:Cannot read property 'style' of undefined 请问有什么解决的办法