哦,只能给你思路,你又不帖完整代码.   把你想要鼠标能拖动的区域另个弄个DIV,获取这个DIV对像进行拖放

解决方案 »

  1.   

    /*
    Auth: jingliangliang
    Date: 2008-5-5
    Email: [email protected]
    */
    (function(){
    if(typeof Drag != "undefined")
    {
    var _Drag = Drag;
    }
    //此处声明Drag类
    //--elementid:要移动元素的ID
    var Drag = window.Drag = function(elementid){
    var thisDrag = this;
    this.DifWidth = 0;
    this.DifHeight = 0;
    this.thisDivDrag = document.getElementById(elementid);
    this.thisDivDrag.onmousedown = function(event){
    var theevent;
    var theSrcevent;
    if(window.event)
    {
    theevent = window.event;
    theSrcevent = window.event.srcElement;
    }
    else
    {
    theevent =event;
    theSrcevent =event.target;
    }
    thisDrag.DifWidth= theevent.clientX - theSrcevent.offsetLeft;
    thisDrag.DifHeight = theevent.clientY - theSrcevent.offsetTop;
    document.body.onmousemove =function(event){
    var theevent;
    if(window.event)
    {
    theevent = window.event;
    }
    else
    {
    theevent =event;
    }
    thisDrag.thisDivDrag.style.left = theevent.clientX -thisDrag.DifWidth ;
    thisDrag.thisDivDrag.style.top = theevent.clientY -thisDrag.DifHeight ;
    };
    document.body.onmouseup =function(event)
    {
    document.body.onmousemove = "";
    };
    };
    };
    })();
    ========================调用<HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
      <script type="text/javascript" src="DragClass.js"></script>
      <script type="text/javascript">
    window.onload=function(){
    __Drag = new Drag("div1");
    };
      </script>
     </HEAD> <BODY>
      <div id="div1" style="background-color:red;width:100px;height:100px;border:1px solid #666666;position: absolute;">test</div>
     </BODY>
    </HTML>
      

  2.   

    父窗口传递信息给子窗口看代码实例:
    <script language=javascript>function outPut()
    {
     //获取父窗口的文本信息赋值给text
     var text = document.abc.text.value;
     //打开子窗口,并且把操作句柄赋值给win变量,以下所有操作都是针对win对象的
     var win = window.open("","mywin", "menubar=no,width=400,height=100,resizeable=yes");
     //输出基本信息
     win.document.writeln("<title>输出结果</title>");
     win.document.writeln("你的信息是:<p>");
     //输出从父窗口获取的信息
     win.document.writeln(text);
     win.document.close();
     win.focus();
    }
    </script><form name=abc method=post>
    <input type=text name=text size=50>
    //调用上面的函数
    <input type=button value=提交 onClick="outPut()"></form>来源:http://www.lamp9.cn/articleshow-6-41560.html
      

  3.   

    这个往div里添加文本框 ,移动文本框依然会动!!!点文本框不移动的那种,,比如鼠标只能放在标题栏那儿才可以移动!!就好像windows窗口!
      

  4.   

    那给你段代码你参考下吧。拖动上面的蓝色部分会移动,而拖动其他位置则不移动。和你想要的效果思想是一样的。
    http://www.cnblogs.com/cloudgamer/archive/2008/11/17/Drag.html