我有2页,page1.html(mypage)和page2.html(外部),page1.html使用iframe加载page2.html。 page2.html基本上有用户信息,它包含菜单,表格。 下面的代码有一个注销功能
$('#inetLogoutId').click(function(event) { var logoutMsg = "Are you sure you want to log out?"; dialogConfirm(logoutMsg, function() { top.document.location.href = path + "/logout"; }) });由于Uncaught DOMException: Blocked a frame with origin "https://example.com" from accessing a cross-origin frame.注销无法正常工作Uncaught DOMException: Blocked a frame with origin "https://example.com" from accessing a cross-origin frame. ,如果将logout函数修改为window.top.location.href ,该怎么window.top.location.href ? 这两者之间的主要区别是什么?
谢谢
i have 2 pages, page1.html(mypage), and page2.html(external), page1.html is loading page2.html using iframe. page2.html have basically information of user, it contain menus , forms. There is a logout function with below code
$('#inetLogoutId').click(function(event) { var logoutMsg = "Are you sure you want to log out?"; dialogConfirm(logoutMsg, function() { top.document.location.href = path + "/logout"; }) });logout not working because of Uncaught DOMException: Blocked a frame with origin "https://example.com" from accessing a cross-origin frame., what if logout function is modified to window.top.location.href. What's the main difference between these 2.
Thank you
最满意答案
当iframe位于不同的域名时,您无法访问iframe的父级。
虽然你可以用另一种方式解决这个问题: http : //madskristensen.net/post/iframe-cross-domain-javascript-calls
You cannot have acces to the parent of the iframe when it is on a different domain name.
Although you can solve this in another way: http://madskristensen.net/post/iframe-cross-domain-javascript-calls
更多推荐
发布评论