在做 iframe的文本編輯器 firfox ,chrome獲得range對(duì)象沒問題
<div class="button" onclick="p1()">bold2</div>
<iframe id="editor" name="editframe" width="600px" height="400px" style="border:solid 1px;"></iframe>
<script type="text/javascript">
function p1(){
var sel=editframe.document.selection.createRange()
alert(sel.text)
}
seajs.use(["t1/iframejs"])
</script>
可是 ie通過editframe.document.selection.createRange()資料上ie都是這個(gè)方法,輸出的選中對(duì)象確為空。
比較一下ie下,我點(diǎn)擊 bold2,iframe中的選中焦點(diǎn)就消失了,firfox, chrome確不會(huì)有這個(gè)問題,是這個(gè)原因嗎,怎么解決。
js iframe文本編輯器,針對(duì)ie
慕斯王
2018-12-06 11:57:09