Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Blocking iframes (twitter/youtube...)

Many websites use iframes to display videos, tweets, etc. It is therefore necessary to ask users for their consent before loading the content of the iframe.

Examples of services using iframes

  • Video players: YouTube, Vimeo, Dailymotion, etc.

  • Social media: Twitter, Facebook, etc.

  • Podcast players.

  • Audio players.

Method 1: Using the SDK

The SDK blocks the iframes of the page that match a selector and displays a customizable blocking message instead:

A blocking message displayed in place of a YouTube video, with the I accept button
The blocking message in place of the video

A click on the button of the message automatically records consent to the service and loads the iframe. If the visitor later withdraws consent to this service, the iframe is blocked again. The message offers an acceptance button only.

An example with YouTube video player iframes:

The iframeBlock options are:

Option
Purpose

selector

CSS selector of the iframes to block.

service

Identifier (slug) of the service whose consent unblocks the iframe.

body

HTML text of the blocking message.

buttonLabel

Label of the acceptance button.

buttonClass

CSS classes of the button.

footer

HTML text displayed under the button.

You can customize the look of the message (background, fonts, etc.) with your CSS stylesheet. The blocking message is added to the page with the .datra-blocking-iframe class.

Method 2: Manual implementation

You can also implement your own logic:

Last updated

Was this helpful?