html: '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="Content.aspx"></iframe>'以上这句代码,能不能将 src=变量,那么就可以不用写死,如果能,应该如何操作。

解决方案 »

  1.   

    在后台定义个public变量iframe ,然后src='<%=iframe%'
      

  2.   


    <iframe scrolling="auto" id="ifrm" frameborder="0" width="100%" height="100%"></iframe>'<script>
    document.getElementById("ifrm").src = "XXXX.aspx;
    </script>
      

  3.   

    <iframe id="iframe1" scrolling="auto" frameborder="0" width="100%" height="100%" src="Content.aspx" runat="server"></iframe>后台:iframe1.Attribute["src"]="";
      

  4.   

    <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="Content.aspx"></iframe>这种方式调用Iframe有两个诟病: a.性能问题(SRC指向的页面内容多时或很长时,加载速度特别慢)
     b.高度自适应问题给你个完美的解决方案:iframe异步加载
    <SCRIPT>    
    function createIframe() {   
        var i = document.createElement("iframe");   
        i.id="NewsFrm";   
        i.src = <%=this.变量%>;   
        i.scrolling = "no";   
        i.setAttribute("frameborder", "0", 0);   
        i.width = "100%";   
        document.getElementById("FrameArea").appendChild(i);   
    };   
    // Check for browser support of event handling capability   
    if (window.addEventListener) window.addEventListener("load", createIframe, false);   
    else if (window.attachEvent) window.attachEvent("onload", createIframe);   
    else window.onload = createIframe;   function reinitIframe(){   
    var iframe = document.getElementById("NewsFrm");   
    try{   
    var bHeight = iframe.contentWindow.document.body.scrollHeight;   
    var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;   
    var height = Math.max(bHeight, dHeight);   
    iframe.height =  height;   
    }catch (ex){}   
    }   
    window.setInterval("reinitIframe()", 200);  </SCRIPT><body>
    <div id="FrameArea" style="height: auto"></div>
    </body>