JavaScript自动设置IFrame高度的小例子_javascript技巧
function SetIFrameHeight(down) {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
var pTar = null;
if (document.getElementById) {
pTar = document.getElementById(down);
} else {
eval('pTar=' + down + ';');
}
pTar.style.display = "block";
if (Sys.ie) {
if (Sys.ie == '9.0') {
pTar.height = pTar.contentWindow.document.body.offsetHeight + 15 + "px";
pTar.width = pTar.contentWindow.document.body.scrollWidth + "px";
} else if (Sys.ie == '8.0') {
debugger;
pTar.height = pTar.Document.body.offsetHeight + 15 + "px";
pTar.width = pTar.Document.body.scrollWidth + "px";
} else {
pTar.height = pTar.Document.body.scrollHeight + 25 + "px";
pTar.width = pTar.Document.body.scrollWidth + "px";
}
}
if (Sys.firefox) {
pTar.height = pTar.contentDocument.body.offsetHeight + 15 + "px";
pTar.width = pTar.contentDocument.body.scrollWidth + "px";
}
if (Sys.chrome) {
pTar.height = pTar.contentDocument.body.offsetHeight;
pTar.width = pTar.contentDocument.body.scrollWidth;
}
if (Sys.opera) {
pTar.height = pTar.contentDocument.body.offsetHeight;
pTar.width = pTar.contentDocument.body.scrollWidth;
}
if (Sys.safari) {
if (pTar.contentDocument.body.offsetHeight pTar.height = pTar.contentDocument.body.offsetHeight + 10;
} else {
pTar.height = pTar.contentDocument.body.offsetHeight;
}
pTar.width = pTar.contentDocument.body.scrollWidth;
}
}
function SetIFrameHeight(down) {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
var pTar = null;
if (document.getElementById) {
pTar = document.getElementById(down);
} else {
eval('pTar=' + down + ';');
}
pTar.style.display = "block";
if (Sys.ie) {
if (Sys.ie == '9.0') {
pTar.height = pTar.contentWindow.document.body.offsetHeight + 15 + "px";
pTar.width = pTar.contentWindow.document.body.scrollWidth + "px";
} else if (Sys.ie == '8.0') {
debugger;
pTar.height = pTar.Document.body.offsetHeight + 15 + "px";
pTar.width = pTar.Document.body.scrollWidth + "px";
} else {
pTar.height = pTar.Document.body.scrollHeight + 25 + "px";
pTar.width = pTar.Document.body.scrollWidth + "px";
}
}
if (Sys.firefox) {
pTar.height = pTar.contentDocument.body.offsetHeight + 15 + "px";
pTar.width = pTar.contentDocument.body.scrollWidth + "px";
}
if (Sys.chrome) {
pTar.height = pTar.contentDocument.body.offsetHeight;
pTar.width = pTar.contentDocument.body.scrollWidth;
}
if (Sys.opera) {
pTar.height = pTar.contentDocument.body.offsetHeight;
pTar.width = pTar.contentDocument.body.scrollWidth;
}
if (Sys.safari) {
if (pTar.contentDocument.body.offsetHeight pTar.height = pTar.contentDocument.body.offsetHeight + 10;
} else {
pTar.height = pTar.contentDocument.body.offsetHeight;
}
pTar.width = pTar.contentDocument.body.scrollWidth;
}
}
上一篇: php实现在线通讯录的实例
下一篇: php如何写一个轻量级的容器
推荐阅读
-
动态的改变IFrame的高度实现IFrame自动伸展适应高度_javascript技巧
-
扩展JS Date对象时间格式化功能的小例子_javascript技巧
-
用js设置下拉框为只读的小技巧_javascript技巧
-
js 验证密码强弱的小例子_javascript技巧
-
JavaScript设置首页和收藏页面的小例子_javascript技巧
-
js控制iframe的高度/宽度让其自适应内容_javascript技巧
-
javascript中日期转换成时间戳的小例子_javascript技巧
-
用javascript动态调整iframe高度的代码_javascript技巧
-
js实现点击注册按钮开始读秒倒计时的小例子_javascript技巧
-
js固定DIV高度,超出部分自动添加滚动条的简单方法_javascript技巧