Gajus
Gajus

Reputation: 73738

How to prevent an iframe from loading new content?

I want to prevent advertisers from an unauthorized tracking of the users.

Advertisers do this (most often) by using a script that creates a new image element at a set time interval.

Here is an example of the network activity on the page when an advertiser is using this strategy:

network activity

The only way to prevent this programmatically would be to prevent an iframe from being able to make any HTTP requests after a set amount of time from the time the iframe has been created.

Upvotes: 2

Views: 241

Answers (1)

Pekka
Pekka

Reputation: 449385

You can't control third party iframes due to the Same-Origin Policy unless they give you permission using a special response header, which is unlikely in this scenario.

That's a fundamental security feature built into every browser.

But even if you could access those iframes, there is no reasonable way to stop scripts in it from making requests, creating new elements, or basically doing anything they want.

It is up to the user to protect themselves against these things, or up to you not to use iframes that may do this.

Upvotes: 2

Related Questions