久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

HTML5 拖拽移動端

HTML5 Drag amp; Drop for Mobile(HTML5 拖拽移動端)
本文介紹了HTML5 拖拽移動端的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

這是我對 WHATWG HTML5 拖放的實現:

This is my implementation of WHATWG HTML5 Drag and Drop:

function allowDrop(ev) {
    ev.preventDefault();
}

function drag(ev) {
    ev.dataTransfer.setData("Text",ev.target.id);
}

function drop(ev) {
    ev.preventDefault();
    var data=ev.dataTransfer.getData("Text");
    ev.target.innerHTML+=" <p>"+document.getElementById(data).innerHTML+"</p>";
}

.div {
    width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;
}

<div class="div" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
    <div class="div" ondrop="drop(event)" ondragover="allowDrop(event)">
    <button id="drag1" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button>
    <button id="drag2" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button>
</div>

它在 Google Chrome 中運行良好,但在 iOS 或 Android 中卻不行.我已經閱讀過有關此的其他主題,但其中大多數建議使用 jQuery 或 JavaScript 插件.

It works fine in Google Chrome, but not in iOS or Android. I have read other topics about this but most of them suggest using jQuery or a JavaScript plugin.

是否可以讓 HTML 拖放實現在 iOS 和 Android(移動設備)上工作?

Is it possible to make the HTML drag and drop implementation work on iOS and Android (mobile devices)?

推薦答案

不幸的是,除 Internet Explorer Mobile 10 及更高版本和單個已棄用的 Presto 版本的 Opera(現已被替換為基于 Webkit 的版本).請參閱 http://caniuse.com/#feat=dragndrop

Unfortunately Drag and Drop is not currently supported by any mobile browsers except Internet Explorer Mobile 10 onwards and a single deprecated Presto version of Opera (which has now been replaced by Webkit based versions). See http://caniuse.com/#feat=dragndrop

最好的解決方案是檢測對拖放的支持(確保這不會在支持 API 的移動版本的瀏覽器中給你誤報),然后使用 JavaScript 在移動設備上進行 polyfill.這也將有助于在舊版瀏覽器中提供支持,這些版本早于對拖放的原生支持.

The best solution would be to detect support for drag and drop (ensuring that this does not give you false positives in mobile versions of browsers that do support the API) and then use JavaScript to polyfill on mobile devices. This will also help provide support in legacy browser versions that pre-date native support for drag and drop.

您可以使用優秀的 YepNope 條件加載庫來運行測試,然后有條件地加載一個或多個腳本以提供JavaScript 支持拖放,或者您可以使用 Modernizr 來執行 測試并加載腳本.

You can use the excellent YepNope conditional loading library to run the test and then conditionally load one or more scripts to provide JavaScript support for drag and drop, or you could use Modernizr to both carry out the test and load the scripts.

這篇關于HTML5 拖拽移動端的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 亚洲色图网址 | 久久成人一区 | 91精品久久久 | 欧美精品一区二区在线观看 | 日韩成人性视频 | 在线视频 中文字幕 | 久久天堂网 | 欧美日韩黄| 91精品国产综合久久久久久蜜臀 | 亚洲精品久久久久久久久久久 | 欧美一级片在线看 | 亚洲日本欧美日韩高观看 | 国产欧美日韩一区 | 中文字幕亚洲视频 | 亚洲九九 | 99国产精品久久久 | 成人在线欧美 | 美女爽到呻吟久久久久 | 欧美在线视频免费 | 国产精品不卡一区二区三区 | 国产视频黄色 | 精品国产乱码久久久久久图片 | 久久33| 盗摄精品av一区二区三区 | 欧美精品乱码久久久久久按摩 | 成人免费视频网站在线观看 | 国产一伦一伦一伦 | 亚洲 欧美 综合 | 亚洲福利 | 在线中文字幕视频 | 成人黄色电影在线观看 | 一区在线视频 | 高清黄色毛片 | 精品av天堂毛片久久久借种 | 激情欧美日韩一区二区 | 久久黄视频 | 精品国产91亚洲一区二区三区www | 国产成人一区二区三区 | 91精品国产综合久久香蕉麻豆 | 嫩草伊人| 一区二区三区在线免费观看 |