我怀疑这实际上是可能的,但我准备纠正。
我需要的是能够从iframe中检测iframe的宽度和高度,所以如果是iframe src
是 iframeContent.html
我需要能够在此页面上显示值。
我无法控制仅托管iframe的页面iframe的内容。
这可能吗?
我怀疑这实际上是可能的,但我准备纠正。
我需要的是能够从iframe中检测iframe的宽度和高度,所以如果是iframe src
是 iframeContent.html
我需要能够在此页面上显示值。
我无法控制仅托管iframe的页面iframe的内容。
这可能吗?
无论页面是否加载,您都可以随时获取网页尺寸 iframe
或者一个新窗口它总是以相同的方式工作。这是我以前发现的功能 window
尺寸,您也可以用它来获得 <iframe>
尺寸。
function alertSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
window.alert( 'Width = ' + myWidth );
window.alert( 'Height = ' + myHeight );
}
无论页面是否加载,您都可以随时获取网页尺寸 iframe
或者一个新窗口它总是以相同的方式工作。这是我以前发现的功能 window
尺寸,您也可以用它来获得 <iframe>
尺寸。
function alertSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
window.alert( 'Width = ' + myWidth );
window.alert( 'Height = ' + myHeight );
}