吃瓜小夏
2016-05-11 17:09
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
*{margin:0;padding:0;}
ul{list-style:none;}
li{display:block;margin-top:10px;height:100px;width:100px;background-color:#CCC;border:5px solid #FC3}
</style>
<script type="text/javascript">
window.onload=function(){
var ali=document.getElementsByTagName("li");
for(i=0;i<ali.length;i++){
ali[i].onmouseover=function(){startMove(this,200)};
ali[i].onmouseout=function(){startMove(this,100)};
}
}
function startMove(obj,target){
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var speed=(target-parseInt(getStyle(obj,"width")))/8;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(parseInt(getStyle(obj,"width"))==target){clearInterval(obj.timer)}
else{obj.style.width=parseInt(getStyle(obj,"width"))+speed+"px"}
},30)
}
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr]
}
else{return getComputedStyle(obj,false)[attr];}
}
</script>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>代码如上,在Dreamweaver里面运行不了,但在搜狗浏览器里可以运行,求大神解答这是为什么呀?代码有什么错误吗?
嗯经评测 在DW里运行在 FireFox,Chrome,IE8
都可以运行的。
我也遇到了这个问题,代码只在IE中能够运行。firefox和DW均无法运行,请问楼主问题解决了么
JS动画效果
113910 学习 · 1502 问题
相似问题