为什么我的代码不执行啊!!! 就是实现一个简单的文字移动效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="message">Whee!</p>
<script src="scripts/showPic.js">
function positionMessage() {
if(!document.getElementById)return false;
if(!document.getElementById("massage"))return false;
var elem=document.getElementById("massage");
elem.style.position="absolute";
elem.style.left="50px";
elem.style.top="100px";
moveElement("massage",200,100,10);
}
addLoadEvent(positionMessage);
function moveElement(elementID,final_x,final_y,interval) {
if (!document.getElementById)return false;
if(!document.getElementById(elementID))return false;
var elem =document.getElementById(elementID);
var xpos=parseInt(elem.style.left);
var ypos =parseInt(elem.style.top);
if(xpos==final_x && ypos==final_y){
return true;
}
if(xpos<final_x){
xpos++;
}
if (xpos>final_x){
xpos--;
}
if(ypos<final_y){
ypos++;
}
if (ypos>final_y){
ypos--;
}
elem.style.left=xpos+"px";
elem.style.top=ypos+"px";
var repeat="moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
movement=setTimeout(repeat,interval);
}
function addLoadEvent(func){
var oldonload=window.onload;
if(typeof window.onload != 'function'){
window.onload=func;
}else{
window.onload=function () {
oldonload();
func();
}
}
}
</script>
</body>
</html>