如何使用javascript 中的事件在div
网页中移动。onload
并且需要在mouse over
事件被调用时停止这种运动?
<script type="text/javascript">
var wid=1002;
var rmax = wid2;
var tmr = 10;
var intg = 2;
var dir = 2;
function moveIt() {
obj = document.getElementById("d1").style;
curr = parseInt(obj.left);
if (curr > rmax) {
dir = -dir;
}
obj.left = curr + dir + "px";
if ((curr == 0) && (dir < 0)) {
dir = -dir;
}
timer=setTimeout("moveIt()", intg*tmr);
}
function init()
{
setTimeout("moveIt()", intg*tmr);
}
function stoper() {
clearTimeout(timer);
}
function hideDiv() {
$(".floatMainContainer").hide();
$(".floatThankyouContainer").show();
}
</script>
<body onLoad="init()">
<div id="d1" style="border:px solid black; top: 2%; left: 0px; z-index:999999; position:absolute; width:262px; height:6px; background-color:none;" onMouseOver="stoper()" onmouseout="moveIt(),10000" >
<div class="floatMainContainer" >
<span class="close">
<span>Close</span>
</span>
</div>
</div>
</body>
</html>