Alin
Alin

Reputation: 1228

Uncaught DOMException: Failed to read the 'contentDocument'

Ever since I have installed an SSL certificate, I have an issue with running a js targeting some information coming from an iframe.

I keep getting:

Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "https://www. *** .ro" from accessing a cross-origin frame.

While searching the internet I found out this is a security issue that won't allow you to load files from another domain or subdomain but the thing is, I am not loading from a subdomain or a different domain. I am loading directly from the same domain/iframe.php .

This happened right after adding an SSL certificate, before that, the exact same script worked without issues.

Upvotes: 1

Views: 10071

Answers (2)

Alin
Alin

Reputation: 1228

The issue was one of absolute vs relative url for the iframe.

I initially used the website's full url (https://www.***.ro/iframe.php) which made it look like trying to load a page from another domain even if it wasn't. Once I changed it to simply ../iframe.php everything is back to normal.

Upvotes: 1

Raymond Nijland
Raymond Nijland

Reputation: 11602

Try using object and embed to simulate a iframe maybe this works

<object data="https://...." width="600" height="400">
    <embed src="https://...." width="600" height="400"> </embed>
</object>

Upvotes: 1

Related Questions