zoukankan      html  css  js  c++  java
  • frameset子窗口获取父窗口失败原因?

    报错信息:

    arrow.html:44 Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

    报错代码:

     1 $(".main").click( function() {
     2         var tartget = window.parent;
     3         var tartget1 = window.parent.window;
     4         var tartget2 = window.parent.window.document;  // 子窗口获取父窗口失败
     5         var tartget3 = window.parent.window.document.getElementById("mainFrameset");
     6         var mainFrameset = window.parent.window.document.getElementById("mainFrameset");
     7         if(mainFrameset.cols == "200,6,*") {
     8             mainFrameset.cols = "0,6,*";
     9             $(".main").removeClass("leftArrow");
    10             $(".main").addClass("rightArrow");
    11         } else {
    12             mainFrameset.cols = "200,6,*";
    13             $(".main").removeClass("rightArrow");
    14             $(".main").addClass("leftArrow");
    15         }
    16     })

    解决方案:

    把代码放到服务器上跑。

    源码地址(静态html):http://files.cnblogs.com/files/xiluhua/frameset_html.rar

    源码地址(服务器):http://files.cnblogs.com/files/xiluhua/frameset.rar

  • 相关阅读:
    绑定方法与与绑定方法
    组合 多态 封装
    继承
    面向对象
    函数进阶
    文件操作
    字符编码
    python基本数据类型及操作
    IDEA 错误: 找不到符号
    Spring+MVC Controller层接收App端请求的中文参数乱码问题。
  • 原文地址:https://www.cnblogs.com/xiluhua/p/4390508.html
Copyright © 2011-2022 走看看