1

I want jquery or javascript to access DOM in Iframe.

For example, I make a iframe to show amazon. then I wanna get a banner image link on amazon. Can I do this?

and I have one more problem. if I click amazon banner that is made a by _blank target on "a" Tag in a iframe, browser make a new tab. but I wanna see a new page in a iframe.

4
  • To open a link in an iframe, use the name of an existing iframe as the target instead of "_blank". Commented Nov 25, 2017 at 8:24
  • Possible duplicate of How to access the content of an iframe with jQuery?. But the page and iframe content should be from same domain. Commented Nov 25, 2017 at 8:44
  • @Alexander More relevant dupe would then be: stackoverflow.com/questions/364952/… Commented Nov 25, 2017 at 8:46
  • 1
    @A.Wolff , I was adding similar comment to my flag.. :) Commented Nov 25, 2017 at 8:50

1 Answer 1

2

You cannot do that if the origin of the iframe is different from the parent document : https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

Sign up to request clarification or add additional context in comments.

2 Comments

As a side node, it is possible in some cases athought that implies the iframed page needs to expose window.postMessage(). Anyway your answer regarding amazon is correct!
Thank you for your answer. and I just decided to use request module. and show using echo html source on child page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.