日期:2014-05-16 浏览次数:20655 次
<script type="text/javascript">
//Ifream子页自适应大小(写在子页中)
var error;
function iframeAutoFit() {
try {
if (window != parent) {
var a = parent.document.getElementsByTagName("IFRAME");
for (var i = 0; i < a.length; i++) {
if (a[i].contentWindow == window) {
var h = document.body.scrollHeight-5;
if (document.all) { h += 4; }
if (window.opera) { h += 1; }
a[i].style.height = h + 'px';
}
}
}
}
catch (error) {
alert(error.message);
}
}
window.attachEvent("onload", iframeAutoFit); //此处与原脚本有区别
</script>
function addEvent(el,name,fn){
if(el.addEventListener) return el.addEventListener(name,fn,false);//在火狐中会执行这一句
return el.attachEvent('on'+name,fn);//在ie中执行这一句
}
addEvent(window,"load",iframeAutoFit)