zoukankan      html  css  js  c++  java
  • iframe跨子域

    主页面

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    复制代码
    <script>
        
    //两个页面必须都包含下面的设置,domain设置只支持跨子域
        document.domain = "84ren.com";
        
    function test() {
            
    //获取正文高度
            document.getElementById("ifm").height = document.getElementById("ifm").contentWindow.document.screen.availHeight;
            
    //获取总高度
            //document.getElementById("ifm").height = document.getElementById("ifm").contentWindow.screen.availHeight;
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        
    <title></title>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div>
        
    <iframe src="http://test2.dealer.ucar.cn/error.aspx" frameborder="0" scrolling="no" onload="javascript:{test();}" width="960" id="ifm" name="ifm"></iframe>
        
    </div>
        
    </form>
    </body>
    </html> 
    复制代码

     iframe页面

     只要保证包含document.domain = "84ren.com"即可实现调用

  • 相关阅读:
    1908-逆序对(归并板子)
    4939-Agent2-洛谷
    1020-导弹拦截-洛谷
    5239-回忆京都-洛谷3月赛gg祭
    5238-整数校验器-洛谷3月赛gg祭
    最大子矩阵
    最长上升子序列(LIS)
    Zk单机多实例部署
    Zk集群部署
    zk单点部署
  • 原文地址:https://www.cnblogs.com/zcm123/p/2684965.html
Copyright © 2011-2022 走看看