iframe大小 - 跨浏览器问题 [英] iframe sizing - cross browser issue
问题描述
我在我的一个网页中显示来自外部网站(我拥有)的网页,位于 iframe
中。除非在浏览器窗口缩小(不宽屏),当 iframe
收缩和压缩内容时,在Opera中观看时,这一切都很好。它工作在宽屏(最大化浏览器窗口),并在IE7,Firefox,Chrome和Safari在最大化和缩小窗口大小是确定。
我在HTML中设置了框架尺寸,并在 div
中嵌入了 iframe
比
I am displaying pages from an external site (that I own) in an iframe
in one of my pages. It's all fine except when viewed in Opera with the browser window size reduced (not widescreen), when the iframe
shrinks and squashes the content. It works in widescreen (maximize browser window), and is OK in IE7, Firefox, Chrome and Safari in maximize and reduced window size.
I have set the frame dimensions in the HTML and have nested the iframe
in a div
which is larger than the iframe
via the css.
这是Opera的一个特殊的错误或者我可以做的事情
Is this a peculiar bug to Opera or is there something I can do about it?
推荐答案
我们有一个类似的问题, iframe
web应用主页,虽然在IE6。解决方案是捕获 window.onresize
事件,并调用JavaScript函数以适当地调整 iframe
的大小。 content
是我们想要的大小的 iframe
的名称。还要注意,我们使用ASP.Net AJAX的 $ get
,其翻译为 document.getElementById()
We had a similar issue with iframe
sizing on our web app main page, although in IE6. The solution was to trap the window.onresize
event and call a JavaScript function to appropriately size the iframe
. content
is the name of the iframe
we want sized. Also note that we are using ASP.Net AJAX's $get
which translates to document.getElementById()
window.onresize=resizeContentFrame;
resizeContentFrame();
function resizeContentFrame() {
setFrameHeight($get('content'));
}
function setFrameHeight(f) {
if(isDefined(f)) {
var h=document.documentElement.scrollHeight;
h-=(HEADER_HEIGHT+CONTENT_PADDING+5);
f.style.height=h+'px';
}
}
这篇关于iframe大小 - 跨浏览器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!