I am making an internal tool for to modify an iframe but chrome throw an error.
This is my html:
<iframe src="https://sportmaniacs.com/es/services/inscription/mitja-marato--10k-ciutat-de-tarragona-2019/5d63d5fc-bb64-4c09-98d6-7440ac1f1c51"
frameborder="0"
></iframe>
This is my js:
const iframe = this.iframe.nativeElement
if ( (iframe.contentDocument || iframe.contentWindow.document).readyState === 'complete' ) {
iframe.onload = this.onIframeLoad.bind(this)
} else {
if (iframe.addEventListener) {
iframe.addEventListener('load', this.onIframeLoad.bind(this), true)
} else if (iframe.attachEvent) {
iframe.attachEvent('onload', this.onIframeLoad.bind(this))
}
}
function onIframeLoad() {
const base64String = this.iframe.nativeElement.contentWindow.document.body.innerHTML
console.log(this.iframe.nativeElement.contentWindow.document.body.children[1].currentSrc)
console.log(base64String)
}
But this code:
iframe.contentWindow.document
Thow this error:
Blocked a frame with origin "http://localhost:5200" from accessing a cross-origin frame
Could I skip the error someway? perhaps with a plugin or something...