JS 倾斜移动图片浏览器不兼容 求大神指点如何兼容谷歌 火狐
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/l...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<style>
#d1{
position:absolute;
}
</style>
<script>
var top = 0;
var left =0;
var top_y = 1;
var left_x = 1;
function f1(){
var d1 = document.getElementById('d1');
var im =document.getElementById('im');
top += top_y;
left +=left_x;
d1.style.top = top+'px';
d1.style.left = left+'px';
if(top > (innerHeight-im.height) || top<0){
top_y = -top_y;
}
if(left > (innerWidth-im.width) || left < 0){
left_x = -left_x;
}
}
setInterval('f1()',-10);
</script>
<body>
<div id='d1'><img src='02.jpg' id='im'/></div>
</body >
</html> 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<style>
#d1{
position:absolute;
}
</style>
<script>
var top = 0;
var left =0;
var top_y = 1;
var left_x = 1;
function f1(){
var d1 = document.getElementById('d1');
var im =document.getElementById('im');
top += top_y;
left +=left_x;
d1.style.top = top+'px';
d1.style.left = left+'px';
if(top > (innerHeight-im.height) || top<0){
top_y = -top_y;
}
if(left > (innerWidth-im.width) || left < 0){
left_x = -left_x;
}
}
setInterval('f1()',-10);
</script>
<body>
<div id='d1'><img src='02.jpg' id='im'/></div>
</body >
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询