iframe 的基本操作

1、iframe 下操作父页面
window.parent.document.getElementById //全部支持
window.top //最顶层
ie 下的iframe的onload事件只能用在绑定的形式

2、父页面下操作iframe
oIframe.contentWindow //iframe 的window 全部支持
oIframe.contentDocument //iframe 的window ie6、7下不支持

3、防钓鱼(判断window.top.location.href==window.location.href)
4、iframe 高度自适应
function changeHeight(){
setTimeout(function(){
oIframe.height=oIframe.contentWindow.document.body.offsetHeight;
},100)
}

你可能感兴趣的:(iframe)