html代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="js/positionMessage.js"></script>
<script src="js/addLoadEvent.js"></script>
</head>
<body>
<p id="message">move</p>
</body>
</html>
js代码:positionMessage
function positionMessage()
{
if(!document.getElementById) return false;
if(!document.getElementById("message")) return false;
var elem=document.getElementById("message");
elem.style.position=absolute;
elem.style.left="100px";
elem.style.top="300px";
}
js代码:addLoadEvent
function addLoadEvent(func)
{var oldonload=window.onload;
if(typeof window.onload!='function')
{window.onload=func;}
else
{window.onload=function()
{oldonload();
func();
}
}
}
addLoadEvent(positionMessage);
相关分类