0
Good morning, I am trying to remove an element that is inside an iframe, I am even trying to add a class via jquery but without success, I have tried to use jQuery load, setTimeout and onload by calling a callback but without success.
Someone has a solution to help me.
Note: Pass any console command in the development tool, it works.
Iframe
<iframe id="frame" onload="callback(this)" src="{URL}" width="100%" height="100%"></iframe>
jQuery
<script type="text/javascript">
function callback() {
alert('Carregado');
$('#elementoParaRemover').remove();
};
</script>
So I tried that way too, but it still doesn’t work. The problem is that it doesn’t run anything inside the iframe. Ex: addClass(), remove(), html(), etc... still, thanks for trying to help.
– Joao
What error is giving friend? It is in relation to origin or Cors?
– Maycon F. Castro
Error showing on console. failed to read the 'contentDocument' Property from 'Htmliframeelement': Blocked a frame with origin "SITE" from accessing a cross-origin frame.
– Joao
The problem is that Cors is blocking access to the element. Take a look at this topic the guy teaches you how to disable this: https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame
– Maycon F. Castro