Learn about the events exposed by On-site messaging.
Use the event handler by calling the following function:
The event handler supports the following events:
informationalModalOpened are triggered when a customer clicks the call to action button and the interstitial opens
informationalModalClosed are triggered when a customer closes the interstitial
placementRendered are triggered when placement is rendered
We encourage to use kebab-case, but we also support camelcase eventTypes.
If either the
callback parameter isn't provided, the function will log an error on the console, but will not throw an error to avoid causing issues on the page. If a string is passed for
EventType that is not supported, the function will log an error as well.
Here's an example of how you can use the
window.Klarna.OnsiteMessaging.on function to block the scrolling of the background when the informational modal is opened.
In this example, the merchant is using the
informationalModalOpened to block the scrolling of the background when the interstitial is opened. The
informationalModalClosed event restores the scrolling when the interstitial is closed.