原因其实是iframe加载是需要时间的,它还没加载完我就在js中直接获取对象了,所以获取为空
var i=document.getElementById("iframe");
i.onload=function(){
console.log(i.contentDocument)
console.log(i.contentWindow.document.getElementById("text").innerHTML)
}
原因其实是iframe加载是需要时间的,它还没加载完我就在js中直接获取对象了,所以获取为空
var i=document.getElementById("iframe");
i.onload=function(){
console.log(i.contentDocument)
console.log(i.contentWindow.document.getElementById("text").innerHTML)
}