• Javascript拖动DIV层


    Javascript拖动DIV层代码如下:

    <html>
    <body>
    <style>
    body{font-family:Verdana;font-size:11px;color:#333;}
    #win1{[position:absolute;left:100;top:100;200px;height:150px;border:1px solid #000;}
    .title{100%;background:#000;height:18px;color:#fff;cursor: move;}
    </style>

    <script>
    var move=false;
    var intX;
    var intY;
    function StartDrag(obj)
    {
    if(event.button==1&&event.srcElement.tagName.toUpperCase()=="DIV")
    {
    obj.setCapture();
    obj.style.background="#999";
    intX = event.clientX - obj.style.pixelLeft;
    intY = event.clientY - obj.style.pixelTop;
    move=true;
    }
    }

    function Drag(obj)
    {
    if(move)
    {
    var oldwin=obj.parentNode;
    oldwin.style.left=event.clientX-intX;
    oldwin.style.top=event.clientY-intY;
    }

    }

    function StopDrag(obj)
    {
    obj.style.background="#000";
    obj.releaseCapture();
    move=false;
    }

    </script>

    <div id="win1">
    <div class="title" onMousedown="StartDrag(this)" onMouseup="StopDrag(this)" onMousemove="Drag(this)" >窗口1</div>
    设计家园<br>
    www.dwww.cn .
    </div>

    </body>
    </html>

  • 相关阅读:
    Python中re(正则表达式)模块学习
    Django(第一次使用心得,及总结)
    Lunix 安装VMware tools
    主键自动生成办法
    常用的android弹出对话框
    JDBC_mysql---防sql注入,存储图片
    java实现md5加密
    sql语句批量处理Batch
    连接mysql数据库2+操作入门
    Oracle事物基础
  • 原文地址:https://www.cnblogs.com/citygs/p/1859968.html
Copyright © 2020-2023  润新知