[英]Firefox loads as an url the dropped text in input field
僅在Firefox中,如果我突出顯示文本並將其放到現有文本字段的中間 ,我會收到一條錯誤消息:
該URL無效,無法加載。
我在這里創建了一個示例http://jsfiddle.net/XtGdd/2/
突出顯示drag me
文本。 然后單擊並將其拖動到輸入框的文本中。 - 如果我在輸入文本后刪除它,它將運行正常。 - 如果我將它放在輸入文本中,我會收到錯誤。
有誰知道為什么會這樣,以及如何解決它?
我想要做的是用刪除的文本字段替換文本字段的值。 在這種情況下,要清除該字段並替換為刪除的文本。
我在http://jsfiddle.net/XtGdd/12/找到了一個解決方案,感謝這個問題
$('#text_input_')
.bind("dragover", false) #=> for Chrome to catch the drop event;
.bind("dragenter", false) #=> for Chrome to catch the drop event;
.bind('drop', function(e){ #=> Cancel the drop and just set the value directly;
$('#text_input_').val(e.originalEvent.dataTransfer.getData("text/plain"));
return false;
});
我真的覺得不安全,但此刻,這是我發現的唯一一件事。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.