I'm working on a project that requires the use of an iframe on the main website (forced on https://www.domain.com), which loads a page with a form on a sub domain (https://my.domain.com). When the form is sent on mobile the main website stays on the position it was when the form was sent, while we want it to scroll to the top of the page. To do this, we want to use the following javascript from the iframe (subdomain):
$(document).ready(function(){
$(this).scrollTop(0);
if(typeof window.parent != 'undefined')
{
window.parent.scroll(0,0);
}
}
Doing this however leads to the following error in the console
Uncaught DOMException: Blocked a frame with origin "https://my.domain.com" from accessing a cross-origin frame.
at HTMLDocument.<anonymous> (https://my.domain.com/files/js/aanmelden.js:160:16)
at i (https://my.domain.com/files/js/vendor/jquery-1.12.0.min.js:2:27451)
at Object.fireWith [as resolveWith] (https://my.domain.com/files/js/vendor/jquery-1.12.0.min.js:2:28215)
at Function.ready (https://my.domain.com/files/js/vendor/jquery-1.12.0.min.js:2:30008)
at HTMLDocument.K (https://my.domain.com/files/js/vendor/jquery-1.12.0.min.js:2:30370
We have tried to set a document.domain
on the subdomain to www.domain.com and domain.com, but this did not solve the issue.
What can we do to solve this issue?