<script>
window.open('1.htm')
</script>
<body>
</body>1.htm:<style>
img{width:200px;height:200px;t:expression(this.ondrag=function(){move(this)})}
</style>
<script>
function move(obj)
{  
  window.opener.document.body.innerHTML+=(obj.outerHTML);
  obj.removeNode(true);
}
</script>
<body>
<img src="1.jpg"><br>
<img src="1.gif">
</body>

解决方案 »

  1.   

    效果基本上是这样的,不过有点要求:
    在父页面中我要指定这个img放到某个td中,如何实现?另外在子窗口中,目前是鼠标在两个图上点击一下,然后随便在子窗口中拖动一下就反映到父窗口中了,能否做到当鼠标拖动到父窗口时,才把这个图片显示在父窗口中的对应位置上?鼠标在子窗口中移动则不做处理?
      

  2.   

    在父页面中我要指定这个img放到某个td中,如何实现?
    <style>
    td{background-color:red;width:100px;height:100px}
    </style>
    <script>
    window.open('1.htm')
    </script>
    <body>
    <table>
    <tr><td id='img'></td><td></td></tr>
    </table>
    </body>1.htm:<style>
    img{width:200px;height:200px;t:expression(this.ondrag=function(){move(this)})}
    </style>
    <script>
    function move(obj)
    {  
         window.opener.document.getElementById('img').innerHTML+=(obj.outerHTML);
         obj.removeNode(true);
    }
    </script>
    <body>
    <img src="1.jpg"><br>
    <img src="1.gif">
    </body>
      

  3.   

    另外在子窗口中,目前是鼠标在两个图上点击一下,然后随便在子窗口中拖动一下就反映到父窗口中了,能否做到当鼠标拖动到父窗口时,才把这个图片显示在父窗口中的对应位置上?鼠标在子窗口中移动则不做处理?
    ========================>当鼠标拖动到父窗口时,IE会自动显示图片,也就是说父窗口会重定向到这个图片的url,原来的父页面不再存在,这是IE的一个特性.可以用代码检测到图片拖动到父窗口,但是无法阻止父窗口的url重定向
      

  4.   

    那如果我拖动某个div会不会也会出现父窗口的url重定向的问题?
    也就是说,我把图片放到某个div中,然后让父窗口显示这个div块?
      

  5.   

    1.htm:<style>
    img{width:200px;height:200px;t:expression(this.ondragend=function(){move(this)})}
    #movePic{width:200px;height:200px;background-color:red}
    </style>
    <script>
    function move(obj)
    {  
         if(document.elementFromPoint(event.clientX,event.clientY).id=='movePic')
          {
            window.opener.document.getElementById('img').innerHTML+=(obj.outerHTML);
            obj.removeNode(true);
          }
    }
    </script>
    <body>
    <img src="1.jpg"><br>
    <img src="1.gif">
    <div id="movePic"></div>
    </body>