<style>  
.aa {position:relative;cursor:move;}  
</style>  
<script language="javascript">  
<!--  
// Author:  Unkonw  
// Modify:  枫岩@CnLei.com  
var ie=document.all;  
var nn6=document.getElementById&&!document.all;  
var isdrag=false;  
var y,x;  
var oDragObj;  function moveMouse(e) {  
 if (isdrag) {  
 oDragObj.style.top  =  (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";  
 oDragObj.style.left  =  (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px";  
 return false;  
 }  
}  function initDrag(e) {  
 var oDragHandle = nn6 ? e.target : event.srcElement;  
 var topElement = "HTML";  
 while (oDragHandle.tagName != topElement && oDragHandle.className != "aa") {  
 oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;  
 }  
 if (oDragHandle.className=="aa") {  
 isdrag = true;  
 oDragObj = oDragHandle;  
 nTY = parseInt(oDragObj.style.top+0);  
 y = nn6 ? e.clientY : event.clientY;  
 nTX = parseInt(oDragObj.style.left+0);  
 x = nn6 ? e.clientX : event.clientX;  
 document.onmousemove=moveMouse;  
 return false;  
 }  
}  
document.onmousedown=initDrag;  
document.onmouseup=new Function("isdrag=false");  </script>  
</head>  
 
<body >
<img src="http://webdesign.chinaitlab.com/UploadFiles_8014/200612/20061202115506895.gif" class="aa" />  
<img src="http://webdesign.chinaitlab.com/UploadFiles_8014/200612/20061202115506895.gif" class="aa" /> 
<img src="http://webdesign.chinaitlab.com/UploadFiles_8014/200612/20061202115506895.gif" class="aa" /><br /><br />  
<div class="aa"> <INPUT TYPE="text" NAME="test" value="test" onclick="msg()"></div>  
</body >

解决方案 »

  1.   

    我想笨的办法就是判断坐标了,文本的坐标了。然后触发function
      

  2.   

    ie下的textarea不支持图片拖放~~ff的可以~~如果就以上说的效果,可以模拟一个~~<html>
    <script>
    window.onload=function(){
        document.onmouseover=function(){
            window.theImg=null;
        }
        var imgs=document.images;
        for(var i=0;i<imgs.length;i++){
            var img=imgs[i];
            img.ondrag=function(){
                window.theImg=this;
            }
        }
        var txt=document.getElementById("txt");
        txt.onmouseover=function(){
           if(window.theImg!=null)this.value=window.theImg.title;
        }
    }
    </script>
    <body>
    <img src="01.jpg" style="width:200;height:200" title="图片1" />
    <img src="02.jpg" style="width:200;height:200" title="图片2" /><textarea id="txt"></textarea>
    </body>
    </html>
      

  3.   

    if(window.theImg!=null)this.value +=window.theImg.title; 呵呵 可以了~~ 给分  ~
      

  4.   

    晕  刚看明白,<textarea id="txt"></textarea> 这个ID 是未知的!!  he_8134(只有星星伴明月) 你的方法不行~~ 汗,分都给了~~
      

  5.   

    自己解决了,贴出来给大家PP
    <html>
    <body>
    <p>
      <script>
    var is_add_text=false ; function drage_init(){  
      is_add_text=false ;
    }function abc(img){ 
     
    var textareas=document.all;

    for(var i=0;i<textareas.length;i++){  
        var obj = textareas[i]; 
    if ((obj.type == 'textarea')||(obj.type=='text')){

    add_word(obj,img);
     
    }
    }
     
    }function add_word(obj,img){ obj.onmouseover = function(){
    if ((obj!=null)&&(is_add_text==false)){ 
    obj.value += img.title+"    ";
    obj=null;
    is_add_text = true;
    }
    }; 
     

    </script> 
    <div style="background-color:#FF0000; width:500px; height:200px;"  >
    <img src="http://www.baidu.com/img/logo-yy.gif" ondragend="abc(this);this.style.url='http://webme.bokee.com/inc/mouse049.ani'" onmouseover="drage_init()" title="http://www.baidu.com/img/logo-yy.gif" /></p>
    </div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p><p>
    <textarea id="a"  style="height:200px; width:300px;" ></textarea>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <textarea id="b"  style="height:200px; width:300px;" ></textarea>
    </body>
    </html>