Magento – Blocked a frame with origin from accessing a cross-origin frame

javascriptjquerymagento2

when I want to go onclick to next page's specific div it shows this error .

jquery.js:3123 Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin from accessing a cross-origin frame.

and not going on specific div just on page.

EDIT

 <div class="col-sm-12 main-image"><img onclick="document.location='/discovers/styles-services#cat_eye';" src="pub/media/before-after/No/Back.jpg" /></div>

Best Answer

This will likely be down to either trying to access an iFrame with Javascript, or you're trying to load an asset from a different server? I can't quite tell from your question sorry, it's not very clear.

You can't access an <iframe> with Javascript, it would be a huge security flaw if you could do it. For the same-origin policy browsers block scripts trying to access a frame with a different origin.

Origin is considered different if at least one of the following parts of the address isn't maintained:

<protocol>://<hostname>:<port>/path/to/page.html Protocol, hostname and port must be the same of your domain, if you want to access a frame.

Answer taken from this stack exchange post