日期:2014-05-16 浏览次数:20462 次
<html>
<head>
<title>凉宫跑来跑去喵~</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<DIV id="div1"
style="Z-INDEX: 100;
LEFT: 2px;
WIDTH: 120px;
POSITION: absolute;
TOP: 43px;
HEIGHT: 120px;
visibility: visible;">
<img id="img1"
src="bg.jpg"
border="0"
height="130"
width="130"
onMouseDown="EIFaction()"
draggable="false"
/>
</DIV>
<SCRIPT src="js.js"></SCRIPT>
</body>
</html>
var EIFx = 300;//EIF初始X坐标
var EIFy = 200;//EIF初始Y坐标
var speed = 30; //计时器参数
var step = 1;//精灵移动速度
var Ylimit = 0;//Y坐标极限范围
var Xlimit = 0;//X坐标极限范围
var Xc = true;//X反向移动参数
var Yc = true;//Y反向移动参数
var EIFh = 0;//EIF身高
var EIFw = 0;//EIF肥胖~卖个萌嘿嘿
var Timer;//计时器
window.onload = function(){
img1.visibility = "visible";//设置img1元素为可见;
Timer = setInterval('EIFmove()', speed);//设置interval代表计时器,并设置周期为speed值,每周期执行一次EIFmove()
Xlimit = document.body.clientWidth;//获取body宽度;
Ylimit = document.body.clientHeight;//获取body高度;
EIFh = div1.offsetHeight;
EIFw = div1.offsetWidth;
var oDiv = document.getElementById('div1')
oDiv.onmousedown = function (){
document.getElementById('img1').src="over.gif"
document.onmousemove =function (ev){
var oEvent = ev || event
left=oDiv.style.left = oEvent.clientX+'px';
top=oDiv.style.top = oEvent.clientY+'px';
EIFx=left;
EIFy=top;
}
document.onmouseup = function ()
{
document.onmousemove = null;
document.getElementById('img1').src="bg.jpg"
}
}
}
function EIFmove()
{
div1.style.left = EIFx + document.body.scrollLeft;
div1.style.top = EIFy + document.body.scrollTop;
if (Yc)
{EIFy = EIFy + step;}
else
{EIFy = EIFy - step;}
if (EIFy < 10)
{Yc = true;EIFy =&