1
一段時間以來,我的頭撞在牆上。execCommand後選擇圖像
我有一個插入圖像的編輯器,但在execCommand運行後我無法在Firefox中選擇新插入的圖像。這是我的代碼。
var editor = this;
var sel = editor._getSelection();
var range = editor._createRange(sel);
editor._doc.execCommand("insertimage", false, imgURL);
img = range.startContainer.previousSibling;
console.log(img);
我同意的情緒,但這不會在IE瀏覽器。另外,OP使用的(未指定的)編輯器幾乎肯定會包含一個iframe,並且有自己的範圍和選擇API,這可能會暴露一個跨瀏覽器的`insertNode()`方法。 – 2011-01-08 17:42:28