js獲取iframe中body內容

獲取iframe中body內容

test-id是iframe的ID

window.frames['test-id'].contentWindow.document.body.innerHTML

//簡單示例,在加入富文本編輯器的頁面中獲取中id爲 ueditor_0 的 iframe 標籤中 body 的內容

<input type="button" value="獲取" onclick="alert(window.frames['ueditor_0'].contentWindow.document.body.innerHTML)">

//一個測試地址:http://ueditor.baidu.com/website/onlinedemo.html
//將上述第5行代碼複製到編輯頁面HTML的一個可見位置即可

發佈了16 篇原創文章 · 獲贊 4 · 訪問量 3888
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章