转:各浏览器获取iframe内容方法以及调试结果

本文介绍了在不同浏览器中通过JavaScript访问iframe内文档内容的方法。包括使用textContent、innerText及XMLDocument等属性来获取内容,并对比了IE6至IE9、Gecko、WebKit等浏览器内核的支持情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://ouyo.info/show.php?pid=1838

iframe.contentWindow.document

     ->iframe.contentWindow.document.documentElement

          ->iframe.contentWindow.document.documentElement.textContent  (W3)

          ->iframe.contentWindow.document.documentElement.innerText   (IE)

     ->iframe.contentWindow.document.XMLDocument

          ->iframe.contentWindow.document.XMLDocument.text

 

 

 

 

contentWindow.document

>.documentElement

>>.textContent

>>.innerText

>.XMLDocument

>>.text

Trident

 

 

 

 

 

 

 

 

 

ie6

 

[object]

[object]

undefined

content

[object]

content

 

ie7

 

 

 

 

 

 

 

 

 

maxthon

[object]

[object]

undefined

content

[object]

content

 

 

360se

[object]

[object]

undefined

content

[object]

bug

 

 

原生

 

 

 

 

 

 

 

ie8

 

[object HTMLDocument]

[object HTMLHtmlElement]

undefined

content

[object]

content

 

ie9

 

[object Document]

[object Element]

content

undefined

undefined

×

gecko

 

 

[object XMLDocument]

[object Element]

content

undefined

undefined

×

webkit

 

 

 [object Document]

[object Element]

content

undefined

undefined

×

presto

 

 

[object XMLDocument]

[object Element]

content

undefined

undefined

×

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值