Reputation: 11
I am trying to access the iframe DOM elements through a Chrome browser extension with something like document.querySelector("iframe").contentWindow.document
The iframe's source is cross-domain. I'm getting a permission error, which Google tells me is because browsers specifically prohibit this.
However, I do have access to the raw DOM on my side from the inspector tool. If I run the same command in the console after inspecting element, I'm able to access the exact inner-HTML element I need with no permission error using the same exact command. I think this is because I'm looking at the DOM rather than trying to grab it from the source, which is what I need, just inside the chrome extension instead and not the chrome console. Is it possible to simply read the DOM of an inner-HTML element in an off-origin iframe? Even if it's not through the chrome extension?
At this point I'm thinking I'd have to edit the chrome browser itself. Please help.
Upvotes: 1
Views: 1894
Reputation: 13087
You can not do this on cross-domain iframes due to security restrictions in the browser. You only option is to get the other site to enable CORS for your site
Upvotes: 1