• div层的拖动(setCapture())


    <!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>
        <style type="text/css">
            #main div {
                position: absolute;
                width: 220px;
                height: 150px;
                border: 1px solid #999;
            }
        </style>
        <script type="text/javascript">
            var a;
            document.onmouseup = function () {
                if (!a)return;
                document.all ? a.releaseCapture() : window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
                a = "";
            };
            document.onmousemove = function (d) {
                if (!a)return;
                if (!d)d = event;
                a.style.left = (d.clientX - b) + "px";
                a.style.top = (d.clientY - c) + "px";
            };
            function $(o, e) {
                a = o;
    //            console.log(a.setCapture)
                b = e.clientX - parseInt(a.style.left);
                c = e.clientY - parseInt(a.style.top);
                document.all ? a.setCapture() : window.captureEvents(Event.MOUSEMOVE);
            }
        </script>
    </head>
    <body>
    <div id="main">
        <div style="left:100px;top:100px;background:#fc9;" onmousedown="$(this,event)">1</div>
        <!--<div style="left:400px;top:100px;background:#9cf;" onmousedown="$(this,event)">2</div>-->
        <!--<div style="left:700px;top:100px;background:#f9c;" onmousedown="$(this,event)">3</div>-->
        <!--<div style="left:100px;top:300px;background:#9fc;" onmousedown="$(this,event)">4</div>-->
        <!--<div style="left:400px;top:300px;background:#c9f;" onmousedown="$(this,event)">5</div>-->
        <!--<div style="left:700px;top:300px;background:#cf9;" onmousedown="$(this,event)">6</div>-->
    </div>
    </body>
    </html>
  • 相关阅读:
    vue简单分屏(1,4,9,16),全屏,还需要调整
    vue 中的Vuex实践
    常用工具类
    java Log日志规范
    spring中对象的注入方式
    不恰当的update语句使用主键和索引导致mysql死锁
    JPA规范及其它持久层框架
    webservice基本功能介绍
    Activiti工作流(二)之常用操作
    Activiti工作流(一)之基本操作介绍
  • 原文地址:https://www.cnblogs.com/yudishow/p/4289696.html
Copyright © 2020-2023  润新知