So there is a parent page on one domain that includes an iframe from a different domain.
I am trying to navigate parent page from the iframe using a relative path that would take base url from the parent.
I tried with
<script type="text/javascript">
function navigateParent(targetPage) {
var url = window.parent.location.href;
if (url.indexOf('.') > -1) {
url = url.substring(0, url.lastIndexOf('/') + 1);
}
window.parent.location = url + targetPage;
}
</script>
but this produces an error:
Unsafe JavaScript attempt to access frame with URL ...my parent url... with URL ...my iframe url... . Domains, protocols and ports must match.
Is there any way to do this? Ie specifiying some cross-domain permission or something.