function getheight() {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject)
Sys.ie = ua.match(/msie ([\d.]+)/)[1]
else if (document.getBoxObjectFor)
Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
if (Sys.ie) {
document.getElementById("iframeHtml").height = iframeHtml.document.body.scrollHeight;//IE下
// document.getElementById("iframe1").height ="500px";
}
if (Sys.firefox) {
document.getElementById("iframeHtml").height = iframeHtml.document.documentElement.scrollHeight + 50;//火狐下
}
}
aspx.cs部分代码:
<iframe id=\"iframeHtml\" src=\"../../../tohtml/GuestListIframe.aspx?" + strUrl[1] + "\" runat=\"server\" name=\"iframeHtml\" frameborder=\"0\" width=\"100%\" onload=\"getheight();\" marginwidth=\"0\" scrolling=\"no\" marginheight=\"0\"></iframe>
iframe自适应高度或自增
最新推荐文章于 2025-05-27 16:02:34 发布
本文详细探讨了如何在HTML和JavaScript中获取iframe元素的高度,在IE和Firefox浏览器之间的差异处理方法,提供了两种不同的实现策略,旨在帮助开发者解决跨浏览器兼容性问题。
588

被折叠的 条评论
为什么被折叠?



