I want to get Content from a website with an iframe and I'm using basysmith`s answer here(https://stackoverflow.com/a/3127056/8177490) to get the content so that I can serve the iframe from my domain.
I want to display only a certain div, let's call it "table-wrap" from the page and have everything else in the iframe hidden.
I've tried almost every answer on this topic but nothing seems to work. When I am using this
var iframeDoc = document.getElementById('iframeid').contentWindow;
jQuery(iframeDoc).find('body > not:#table-wrap').hide();
jQuery(iframeDoc).find('#table-wrap').appendTo('body');
in the console.
I am still getting an error, although it is served from my Script on my Domain:
VM4380:66 Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "https://mydomain.de" from accessing a cross-origin frame.
at HTMLIFrameElement.contentDocumentDesc.get [as contentDocument] (<anonymous>:66:14)
at contents (https://mydomain.de/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:26888)
at Function.map (https://mydomain.de/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:3613)
at a.fn.init.n.fn.(anonymous function) [as contents] (https://mydomain.de/wp-includes/js/jquery/jquery.js?ver=1.12.4:2:27001)
at <anonymous>:1:18
I've tried also different ways with iframe.onload and
jQuery("#iframeID").ready(function () {
jQuery('#iframeid > :not(#table-wrap)').hide();
jQuery('#table-wrap').appendTo('body');
});
But nothing seems to work.
Does anybody have an idea for this how I can get this to work? Would appreciate anything.