日期:2014-05-16  浏览次数:20321 次

关于图片拖进输入框的问题?
怎样在网页中拖动图片进输入框(textarea),输入框中就会显示该图片的的alt或者title   信息。拖动方式就和拖动选种文字一样。当然textarea属性信息是不知道的。

我已经研究很久了,有没有可能实现或者怎么样实现?求那位大人正解!

------解决方案--------------------
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>