G
G
gene40002015-09-26 09:14:20
JavaScript
gene4000, 2015-09-26 09:14:20

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

3 answer(s)
M
Marcuzy, 2015-09-26
@Marcuzy

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.

V
Vitaly Inchin ☢, 2015-09-26
@In4in

window.framesto 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();
});

K
Konstantin, 2015-09-26
@unity_ultra_hardcore

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 question

Ask a Question

731 491 924 answers to any question