0

Let's say I have a page from www.website1.com.

Then I have a iFrame from www.myiframewebsite.com that is embedded in the page with id of iframe1.

I would like to do the following:

var myIframe = document.getElementById('iframe1');
myIframe.contentWindow.scrollTo(xcoord,ycoord);

So basically I would like to interact from parent page with child iFrame as if that iFrame is on same domain. There is a similar question Cross domain iframe issue, but I don't want to use post messages to solve this.

Is there anything in CORS that I can use?

NightOwl888
  • 53,678
  • 21
  • 130
  • 204
Aflred
  • 4,095
  • 6
  • 26
  • 41
  • "I dont want to use post messages" — Post messages are the only way. – Quentin Feb 26 '18 at 13:01
  • It is not duplicate, i do not want to use 'messages' but i want to manipulate it with pure jquery. – Aflred Feb 26 '18 at 13:02
  • Is there a CORS thing that i can use? – Aflred Feb 26 '18 at 13:02
  • No. You can't use CORS for this. – Quentin Feb 26 '18 at 13:03
  • No, CORS is about making (HTTP) requests, but you are not making an HTTP request here. postMessage _is_ what should be used for this; if you just say you “don’t want to” use it without any actual reasoning behind that, then we can leave it at that, then there’s not much more to discuss here. – CBroe Feb 26 '18 at 13:05
  • There is a reason but wont post it here as it is long. Regardless it is obvious that manipulating a child iframe as it is on the same domain is much easier than doing post/get messages. – Aflred Feb 26 '18 at 13:07

0 Answers0