这些javascript代码什么意思?

来源:百度知道 编辑:UC知道 时间:2024/06/16 03:29:03
<script language="JavaScript" type="text/javascript">
var drag_=false
var D=new Function('obj','return document.getElementById(obj);')
var oevent=new Function('e','if (!e) e = window.event;return e')
function Move_obj(obj){
var x,y;
D(obj).onmousedown=function(e){
drag_=true;
with(this){
style.position="absolute";var temp1=offsetLeft;var temp2=offsetTop;
x=oevent(e).clientX;y=oevent(e).clientY;
document.onmousemove=function(e){
if(!drag_)return false;
with(this){
style.left=temp1+oevent(e).clientX-x+"px";
style.top=temp2+oevent(e).clientY-y+"px";
}
}
}
document.onmouseup=new Function("drag_=false");
}
}
</script>
<body>
<div id="test" style="background-color:#0099CC;width:200px;height:100px;border:

onmouseover是鼠标拖动事件~它执行了Move_obj("text")、

D(obj).onmousedown=function(e) 这句意思其实等同于
function D(obj).onmousedown(e) 这样就不难理解了吧~~

在网页上,实现可以托动的层 。

执行拖动效果