iframe自适应高度或自增

来源:互联网 发布:python抓取股票数据 编辑:程序博客网 时间:2024/05/01 16:38
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>

原创粉丝点击