报错信息:
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
时间: 2024-10-09 22:40:43