<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ceshi</title> <mce:style><!-- body{ margin:0px; padding:0px; } #drag { position:absolute; cursor:pointer; } --></mce:style><style mce_bogus="1">body{ margin:0px; padding:0px; } #drag { position:absolute; cursor:pointer; }</style> <mce:script language="JavaScript"><!-- function drags(){ var z= event.srcElement || event.target; temp1=z.style.pixelLeft temp2=z.style.pixelTop x=event.clientX y=event.clientY document.οnmοusemοve=function(){ if (event.button==1){ z.style.pixelLeft=temp1+event.clientX-x; z.style.pixelTop=temp2+event.clientY-y; var newclientwidth = parseInt(document.documentElement.clientWidth)-parseInt(z.style.width); var newclientheight = parseInt(document.documentElement.clientHeight)-parseInt(z.style.height); if(z.style.pixelTop>newclientheight){ z.style.pixelTop = newclientheight; }else if(z.style.pixelTop<=0){ z.style.pixelTop = 0; } if(z.style.pixelLeft>newclientwidth ){ z.style.pixelLeft = newclientwidth; }else if(z.style.pixelLeft<=0){ z.style.pixelLeft = 0 ; } } } } // --></mce:script> </head> <body> <div id="drag" style="width:158px; height:150px; background:#0066CC;" οnmοusedοwn="drags()" ></div> </body> </html>