<script type="text/javascript">
var ob=document.getElementById("b"); //大的div
var ob_w=ob.clientWidth;
var ob_h=ob.clientHeight;
var obj=document.getElementById("a");
var obj_w=obj.clientWidth;
var obj_y=obj.clitentHeight;
var move_w=ob_w-obj_w;
var move_h=ob_h-obj_w;
var a=true;
function move(e)
{
e=e||window.event;
if(obj.offsetLeft!=e.clientX-20)
{
obj.style.left=e.clientX-20+"px";
}
if(obj.offsetTop!=e.clientY-20)
{
obj.style.top=e.clientY-20+"px";
}
//alert(e.clientX>=move_w);
e.clientX>=move_w+40||e.clientY>=move_h+40 ? obj.style.display="none":obj.style.display="block"; //实现小div出界后隐藏,然会又出现
}
ob.onmousemove=move;
</script>