1

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>
0

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

  • If I am trying yo access a div by id like www.learner.com/new#accessdiv still its not going to that div and give this error . – Learner Nov 15 '17 at 10:59
  • It sounds like it may be the URL you are using, is it on the same domain as the page you are on? If so try prepending https:// to the URL or writing the path like this: /new#accessdiv. Are you using an iframe at all? – Ben Crook Nov 15 '17 at 11:10
  • can you see edited code ? I am doing like this – Learner Nov 15 '17 at 11:14
  • What happens if you change the location to 'https://your-url.com/discovers/styles-services#cat_eye'? – Ben Crook Nov 15 '17 at 11:23
  • just page refresh and navigate to where I left page. – Learner Nov 15 '17 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.