0
我有一個iframe文本編輯器。對於插入圖像,我有一段代碼:在Iframe文本編輯器中插入後
.
.
.
var sel = document.getElementById('wysiwygtextfield').contentWindow.getSelection();
// get the first range of the selection (there's almost always only one range)
var range = sel.getRangeAt(0);
// deselect everything
sel.removeAllRanges();
// remove content of current selection from document
range.deleteContents();
// get location of current selection
var container = range.startContainer;
.
.
.
**afterNode = container.childNodes[0];
container.insertBefore(insertNode, afterNode);**
// This does not work
// container.insertAfter(insertNode, afterNode);
問題在於最後兩行。我嘗試使用insertAfter
,但它似乎沒有工作。在插入之前插入所選內容或與其相鄰的元素之前插入。任何方式讓它插入後。這樣,它看起來好像用戶如果從右到左打字而不是從左到右。