IE输入事件是否可编辑? [英] IE input event for contenteditable?
问题描述
我想知道 IE11 中是否有一个polyfill支持 contenteditable 输入事件?
I am wondering if there is a polyfill to support the contenteditable input event in IE11?
I我正在专门谈论此事件: http://jsfiddle.net/ch6yn/
I am specifically talking about this event: http://jsfiddle.net/ch6yn/
只要 contenteditable div发生更改,无论来源如何(例如复制/粘贴/拖放/拖放/类型等),都会触发该操作。
Which fires whenever a change happens on a contenteditable div regardless of the source (e.g. copy/paste/drag/drop/type etc).
<div contenteditable="true" id="editor">Please type something in here</div>
<script>
document.getElementById("editor").addEventListener("input", function() {
alert("input event fired");
}, false);
</script>
推荐答案
今天就解决了这个问题,这就是我解决的方法..
Ran into this today, this was how I solved it..
解决方案:更改事件名称-> textinput在IE 11中可用于事件附件-只需确保让其他浏览器使用输入。
Solution: Change event name --> "textinput" works in IE 11 for event attachment - just be sure you let the other browsers use "input".
示例:
//Check for IE ('Trident')
var eventType = /Trident/.test( navigator.userAgent ) ? 'textinput' : 'input';
//Attach your event
this.refs.captionInput.addEventListener( eventType, this.handleChangeCaption );
这篇关于IE输入事件是否可编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!