【发布时间】:2012-02-01 01:55:21
【问题描述】:
我正在尝试使用 javascript 和 Jquery 动态设置 iframe 的高度。
但由于某种原因,这在 Ie8 和 chrome 中不起作用。 (但它在 Firefox 上运行良好)
有人可以帮忙吗?
谢谢
function resizePanel() {
window.console.log("ran the resize panel function");
var frame = document.getElementsByTagName('iframe')[0];
if(frame != null) {
var height;
if(self.innerHeight) {
window.console.log("ran the self.innerHeight");
height= self.innerHeight;
}
else if (document.documentElement && (document.documentElement.clientHeight)) {
window.console.log("ran the clientHeight");
height = document.documentElement.clientHeight;
}
else if(document.body) {
window.console.log("ran the document.body");
height = document.body.clientHeight;
}
frame.style.height = height - 165 + 'px'
}};
$(document).ready(function() {
resizePanel();
$(window).resize(function() {
resizePanel();
});
});
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequest);
function EndRequest(sender, args) {
resizePanel();
}
【问题讨论】:
标签: javascript jquery iframe cross-browser