日期:2014-05-16 浏览次数:20411 次
<!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=gb2312" /> <title>无标题文档</title> </head> <body> <script> var posX; var posY; var popDiv; var dragable; function down(e){ popDiv = document.getElementById("pop-editor"); e = e || window.event; //如果是IE posX = e.clientX - parseInt(popDiv.style.left); posY = e.clientY - parseInt(popDiv.style.top); dragable = true; document.onmousemove = move; } function move(ev){ if(dragable == true){ ev = ev || window.event;//如果是IE popDiv.style.left = (ev.clientX - posX) + "px"; popDiv.style.top = (ev.clientY - posY) + "px"; } } function up(){ dragable = false; } </script> <div id='pop-editor' style='width: 520px;height:430px;border:1px solid red;position: absolute;left:100px;top:200px;' onmousedown='down(event)' onmouseup='up()'>稍等哈</div> </body> </html>
?