JavaScript methods

Various methods are provided for interaction with other functionalities of the website.
This offers the possibility to control the pop-up or functionalities of the pop-up without interaction from the user, or to request status queries for consent.

Basically, all layouts offer the same methods. This means that the same basic functionality is available regardless of whether TCF mode is activated or not.

Methods

After initialization of the script by the browser, the following methods are available via the window object. For some layouts, it is also possible to call the methods via the window.legalweb.popup object (without the “lw” prefix).

Activate, deactivate and query the status of individual integrations

  • lwEnableIntegration(integrationId: string):void
  • lwDisableIntegration(integrationId: string):void
  • lwIsIntegrationEnabled(integrationId: string):bool

The value of the “data-slug” attribute of the switch in the pop-up is expected as the “integrationId”.

Activate, deactivate categories, query status

  • lwIsIntegrationCategoryEnabled(integrationId):bool
  • lwConsentIabIntegrations(categoryId: string, consentStatus: boolean):void
  • lwConsentIabIntegrations(consentStatus: boolean):void

The following methods simulate “clicks” on the buttons.

  • lwConsentAcceptSelected():void
  • lwConsentDenyAll():void
  • lwConsentIabIntegrations():void

Methods for displaying and closing the popup. Important: no other methods are executed that require consent or rejection.

  • lwShowPopup(options : {tab: string} = null):void
  • lwHidePopup():void
  • lwShowNotice():void
  • lwHideNotice():void

Insert embeddings dynamically

The following method can be used to dynamically create a placeholder for an embedding. A valid DOM node to which the placeholder is appended (via append) is expected as “nodeToAdd”. “integrationSlug” is the ID of the service (e.g. embeddings_youtube, embeddings_googlemaps). “callbackMethod” is the method that is executed as soon as the content is activated by the visitor (via consent). If consent has already been given, “callbackMethod” is executed immediately.
Intended use: e.g: Displaying a preview image of videos instead of the placeholder.

  • lwAddPlaceholderWithCallbackToNode(nodeToAdd, integrationSlug, callbackMethod):void

Manual initialization of the legal web JavaScripts

If popup and/or notice are not loaded via DOMContentLoaded event, a method for user-defined initialization is available. This method initializes the “complete” frontend, but does not yet display anything. In addition, the popup must also be displayed/called manually via the methods mentioned in the previous point.
“language” is the two-character abbreviation of the language (de, en, it, …)

  • lwCdnInit(language: string):void

Temporary deactivation of the Legalweb functions for a request

If the parameter lwDisableLegalweb is appended to a URL, no popup or notice is displayed, no integrations are loaded and no content is blocked.

Similar posts

Measuring consent rates with Matomo

Measuring consent rates with Matomo To be able to measure the consent rate using Matomo, only 1 line of JavaScript ... Weiterlesen ...

Piwik Pro: convert anonymous tracking to advanced tracking

Load as technically necessary and collect more visitor data after consent In our article https://legalweb.io/news/matomo-piwik-pro-rechtskonform-einbinden/ on Piwik Pro, both variants ... Weiterlesen ...

Quickstart

Quickstart/quick guide To log in, you will need the email address and password you entered when you purchased one of ... Weiterlesen ...

JavaScript Events

JavaScript Events Various events are provided for interaction with other functionalities of the website.This offers the possibility to control the ... Weiterlesen ...
Privacy
The controller (legal web GmbH, Austria) would like to use the following services in order to process your personal data. Technologies such as cookies, localStorage, etc. can be used for personalization. This is not necessary for the use of the website, but allows us to interact with you more closely. If you wish, you can adjust or revoke your consent at any time via our privacy policy.