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 "" 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
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." 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
Share Improve this question asked May 15, 2017 at 8:38 Nisar AfridiNisar Afridi 1571 gold badge5 silver badges21 bronze badges 2- 1 For the second part of your question use this link: stackoverflow./questions/3332756/… – Jose Marques Commented May 15, 2017 at 8:42
- 1 You can not use java script to perform this function. Use the link to lern more: stackoverflow./questions/25098021/… – Jose Marques Commented May 15, 2017 at 8:49
4 Answers
Reset to default 1You 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/post/iframe-cross-domain-javascript-calls
we have to use window.top.location.href = path + "/logout";
This is due to same-origin-policy. You have keep your all files on the same website or host. Same-origin policy prevents access to cross origin.
You can use document.referrer
to referrer to the parent window.
https://developer.mozilla/en-US/docs/Web/API/Document/referrer#value