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"即可实现调用

  • 相关阅读:
    LINUX按键驱动程序
    s3c2440地址分配
    Linux内核代码
    C语言初始化
    tftp协议
    ARM工作模式
    Bootstrap3隐藏滑动侧边栏菜单代码特效
    javascript 中slice,substr,substring方法的对比
    vue 的简述
    鼠标移动出自己想要的效果
  • 原文地址:https://www.cnblogs.com/zcm123/p/2684965.html
Copyright © 2011-2022 走看看