Tôi đang xây dựng trình soạn thảo wysiwyg với khung nội tuyến có thể chỉnh sửa bằng cách sử dụng document.execCommand()
. Bây giờ tôi cần phải sử dụng lệnh "insertHTML"
mà hoạt động hoàn hảo trong Chrome và Firefox nhưng tất nhiên nó không hoạt động trong Internet Explorer:execCommand ("insertHTML", ...) trong Internet Explorer
function run() {
document.getElementById("target").focus();
document.execCommand("insertHTML", false, "<b>ins</b>");
}
<div contenteditable id="target">contenteditable</div>
<button onclick="run()">contenteditable.focus() + document.execCommand("insertHTML", false, "<b>ins</b>")</button>
dung dịch chuẩn cho vấn đề này là gì? Không sao nếu nó chỉ hoạt động trong IE8 nhưng hỗ trợ IE7 cũng sẽ tốt hơn.
[These] (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7536602/) [bug reports] (https://github.com/yabwe/ medium-editor/issues/771 # issuecomment-182233090) ngụ ý rằng Edge hỗ trợ execCommand ("insertHTML", ..) (mặc dù với các quirks riêng của nó). – Nickolay