瀏覽器兼容代碼
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 請問有什么解決的辦法
2015-12-30
cssnew[1]