• DIV拖动实例


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>

    <title>mytest-javapig</title>
    <meta http-equiv="content-type" content="text/html; charset=gb2312">
    <meta http-equiv="content-script-type" content="text/javascript">
    <meta http-equiv="content-style-type" content="text/css">


    <style type="text/css">
    .dragclass{
    position : relative;
    cursor : move;
    }
    </style>


    <script type="text/javascript">


    if  (document.getElementById){

    (function(){


    if (window.opera){
    document.write("<input type='hidden' id='Q' value=' '>");
    }

    var n = 500;
    var dragok = false;
    var y,x,d,dy,dx;

    function move(e){
    if (!e) e = window.event;
     if (dragok){
      d.style.left = dx + e.clientX - x + "px";
      d.style.top  = dy + e.clientY - y + "px";
      return false;
     }
    }

    function down(e){
    if (!e) e = window.event;
    var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
    if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){
     temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
     }
    //如果事件是发生在 TR标签,则..
    if('TR'==temp.tagName){
    //指向 TBODY 标签
    temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
    //指向 TABLE 标签
    temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
    //指向 DIV 标签,这样就可以移动啦
    temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
    }

    if (temp.className == "dragclass"){
     if (window.opera){
      document.getElementById("Q").focus();
     }
     dragok = true;
     temp.style.zIndex = n++;
     d = temp;
     dx = parseInt(temp.style.left+0);
     dy = parseInt(temp.style.top+0);
     x = e.clientX;
     y = e.clientY;
     document.onmousemove = move;
     return false;
     }
    }

    function up(){
    dragok = false;
    document.onmousemove = null;
    }

    document.onmousedown = down;
    document.onmouseup = up;

    })();
    }
    </script>


    </head>
    <body>


    <p class="dragclass" style="top:0px;left:0px;200px;text-align:center;background-color:#ff0000;color:#ffffff">
    P tag
    </p>

    <b class="dragclass" style="top:0px;left:0px;background-color:#f40084;color:#ffffff">
    B tag
    </b>

    <div id="test" class="dragclass" style="position:absolute;top:330px;left:160px;height:20px;150px;background-color:#a65000;color:#ffffff">
    Div: Absolute position
    </div>

    <div class="dragclass" style="position:absolute;top:143px;left:120px;height:20px;150px;">
      <table width="100%" height="25" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
      <tr>
        <td>Table</td>
        </tr>
    </table>
    </div>


    <div class="dragclass" style="position:absolute;top:96px;left:152px;height:20px;53px;">
    <img src="http://www.blueidea.com/articleimg/bbsimg/icon9.gif" width="69" height="69">
    </div>

    <div class="dragclass" style="position:absolute;top:60px;left:229px;height:20px;53px;">
    <input name="" type="button" value="Button">

    <div class="dragclass">
      <table width="100%" border="1" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#FFB059">
        <tr>
          <td height="20" bgcolor="#FFDFBB">&nbsp;<strong>&nbsp;这个动弹不得 </strong></td>
        </tr>
      </table>
    </div>

    </body>
    </html> 

    噢耶游戏是中国最大的轻社交游戏开发商,致力于手机页游的研发及推广业务。我们首创性地提出了HTML5游戏中心思路,在第三方App 中嵌入式休闲游戏,为开发者提供了全新的应用内游戏解决方案。
  • 相关阅读:
    ABP 基于DDD的.NET开发框架 学习(四)时间控件采用datetimepicker注意事项
    解决Vs控制台程序出现NuGetprofile.ps1,因为在此系统上禁止运行脚本错误时或提示:“无法加载文件 .nugetpackagesMicrosoft.EntityFrameworkCore.Tools1.1.0-preview4-final oolsinit.ps1,因为在此系统上禁止运行脚本”
    git 本地初始化项目操作
    php(thinkphp)在linux系统下pdf转png图片【转】
    git学习笔记
    git 2.4.5编译安装
    mysql占用内存高的问题
    vmware下虚拟机centos,root登录时候提示鉴定故障解决方法
    SSH.net之主程序
    SSH.net之Service层
  • 原文地址:https://www.cnblogs.com/yintian2/p/777281.html
Copyright © 2020-2023  润新知