問(wèn)題描述
簡(jiǎn)介:
大約在 2017 年 3 月中旬,在將 Firefox 更新到版本 52 后,某些功能(拖放和粘貼)無(wú)法正常運(yùn)行.正如它在調(diào)試時(shí)顯示的那樣,事件的屬性dataTransfer"現(xiàn)在設(shè)置為 null.
At about mid March 2017, after an update of firefox to version 52, certain functions - drop and paste - ceaced to function properly. As it shows up on debugging, the attribute "dataTransfer" of the event is nowadays set to null.
在更新之前,onDrop 和 onPaste 事件都將 dataTransfer 屬性設(shè)置為要?jiǎng)h除或粘貼的內(nèi)容.
Previously to the update, onDrop and onPaste events both delivered the dataTransfer attribut set to the contents of what were to be dropped or pasted.
問(wèn)題:
在實(shí)際瀏覽器中應(yīng)該如何處理拖放和粘貼?這些天有什么必要的預(yù)防措施嗎?現(xiàn)在有限制行為背后的原因嗎?
How should drop and paste be handled with actual browsers? Are there any precautions necessary these days? Is there an explanation out there of the reasons behind the restrictive behavior of nowadays?
互聯(lián)網(wǎng)上是否有任何示例顯示如何使用實(shí)際瀏覽器完成任務(wù)?
Is there any example out there in the internet showing how to accomplish the task with actual browsers?
我不要求 Firefox 48 版之前的示例,因?yàn)橹辽僭谀莻€(gè)版本之前,整個(gè)事情都完美無(wú)缺.我不要求使用 jQuery 或任何其他庫(kù)的示例(如果它們作為附加補(bǔ)充提供,我不會(huì)拒絕這些示例).我確實(shí)要求使用簡(jiǎn)單的原生 javascript 示例.
I do not ask for examples prior to version 48 of firefox, since at least until that version, the whole thing worked flawlessly. I do not ask for examples with jQuery or any other library (while not rejecting those if they come as additional supplements). I do ask for examples with simple plain native javascript.
推薦答案
一步步調(diào)試的時(shí)候,dataTransfer的數(shù)據(jù)好像丟失了.可能是因?yàn)檎{(diào)試中涉及的事件.讀取dataTransfer(ev.dataTransfer.getData)后開(kāi)始一步步調(diào)試,你會(huì)看到dataTransfer不再為空了.
When debugging step by step, the data from dataTransfer seems to get lost. Probably because of the events involved in debugging. Start the step-by-step debugging after the reading of dataTransfer (ev.dataTransfer.getData), and you will see that dataTransfer is not null anymore.
這篇關(guān)于firefox ondrop event.dataTransfer 更新到版本 52 后為空的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!