简体   繁体   中英

Drag and drop not working in chrome

Iam trying to use drag and drop. In an anchor tag I write my onsdragstart event as written down

<a href="xyz.action" ondragstart="event.dataTransfer.setData('text/uri-list', 'abc.action?id=2')">drag</a>  

Im trying to drop the item in a div

<div id="ccc" ondragover="event.preventDefault()" ondrop="doDrop1(event)"></div> 

My javascript is as below:

 function doDrop1(event)
        {

           document.getElementById("mylock").value=1; 
          var links = event.dataTransfer.getData("text/uri-list").split("\n");
           alert(links)
} 

In chrome the alert is 'http://localhost:8084/test/xyz.action' In firefox i'm getting correct alert as 'abc.action?id=2'

“ event.dataTransfer.setData()”中,将数据格式用作“文本”,而不是“文本/ uri-list”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM