<iframe name="t1" src="" width="1095" scrolling="no" frameborder="0" id="external-frame" οnlοad="iFrameHeight()
" style="min-height:
1140px;
"></iframe>1:ifame 根据包含的页面内容自动调整自己的大小,没有边框,没有滚动条近段这使用iframe的时候遇到了一些问题,发现iframe真是不要随便使用,真麻烦function iFrameHeight() {
var ifm = document.getElementById(
"external-frame");
var subWeb = document.frames ? document.frames[
"external-frame"].document : ifm.contentDocument;
if (ifm !=
null && subWeb !=
null) { ifm.height = subWeb.body.scrollHeight; ifm.width = subWeb.body.scrollWidth; }}2:ifame包含的页面修改父类iframe的高度,不同的浏览器或者子页面高度的方法不一样,特别注意ie浏览器跟其他浏览器的不同
function IFrameResize() {
//alert(this.document.body.scrollHeight); //弹出当前页面的高度 var obj =
parent.
document.
getElementById(
"external-frame");
//取得父页面IFrame对象 //alert(obj.height); //弹出父页面中IFrame中设置的高度 if (!!
window.
ActiveXObject ||
"ActiveXObject" in window)
obj.
height =
this.
document.
body.
scrollHeight;//ie浏览器
else obj.
height =
this.
document.
documentElement.
scrollHeight;//其他浏览器}3:修改iframe的url
window.
parent.
frames[
't1'].
location.
href =
url;
转载请注明原文地址: https://ju.6miu.com/read-1302679.html