I am working with two web sites. I have one aspx page with master page in one web site project. I want to use this page as an iframe in my second web site within another page which also has master page. When I do this, I am getting both master pages, while I want to remove the master page from my Iframe.
Simply, How can I access child window's element from top window with different domain?
First I tried to replace master page from code behind on page preInit event but there I can't get child page's master page. So this didn't work for me.
Second solution I tried to remove it from jquery. Here, I am not able to access content of iframe since its from different domain. So, I used Post-message but still the same issue occurs. Here is my code, I tried.
In Parent Page:
window.addEventListener("message", function (e) {
alert(e.origin);
if (e.origin !== 'http://localhost:xxxxx') {
return;
}
alert(e.data);
}, false);
In Iframe Page:
$(document).ready(function () {
window.parent.postMessage("I am loaded", "*");
});
I am getting message in my postmessage but still can't access elements (e.source in my case) inside iframe.
Please help!