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
Popup methods
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.