Answer the question
In order to leave comments, you need to log in
How to prevent iframe from loading in html page?
It is necessary to "protect" the page from displaying third-party iframes on it. For certain reasons, this needs to be done using Javascript. How to track the loading of an iframe or the creation of such elements on the page?
Answer the question
In order to leave comments, you need to log in
The list of js events help.dottoro.com/larrqqck.php would
probably suit DOMNodeInserted to prevent a new frame from being inserted into the page.
window.frames
to help.
A very strange task, of course. Where will the frames come from on the page if you don't add them yourself?
var wF = window.frames;
wF.length&&[].forEach.call(wF, function(frame){
if(frame.src!="http://site.ru") frame.remove();
});
If anything, the modern and standard solution is the X-FRAME-OPTIONS server header with a value of DENY.
But it is clear that it cannot be exposed from the client side.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question