Table of Contents
- Handles events from the web view, such as clicks and form submissions
- Allows you to attach custom event handlers to specific events
- Supports reloading the iframe on demand
- Stores initialization parameters in session storage for easy retrieval
<!DOCTYPE html>
<html>
<title>Mezon Web SDK</title>
<body>
<!-- ... -->
<script src="mezon-web-sdk.js"></script>
<!-- ... -->
</body>
</html>
Now you can use the MezonWebView via window object:
window.Mezon.Webview
An object containing the initialization parameters for the web view
window.Mezon.Webview.postEvent('iframe_ready', () => {})
-
Posts an event from web view to Mezon, along with any associated data which will be sent as a JSON message to the parent window.
-
Handles an incoming event from Mezon. See MezonWebViewEvent for more information on available events.
-
eventType
: The event will be posted to Mezon with this name. -
eventData
: The data associated with the event. -
callback
: An optional callback function that will be executed when the postEvent method completes.
window.Mezon.Webview.postEvent('theme_changed', () => {})
Handles an incoming event from Mezon. See MezonAppEvent for more information on available events.
eventType
: The type of event being received.eventData
: The data associated with the event.
window.Mezon.Webview.onEvent('theme_changed', () => {})
Registers a new handler for a specific event type. If an event of that type is received, it will be called with the associated data.
eventType
: The type of event being registered.callback
: The function to call when the event occurs.
window.Mezon.Webview.offEvent('theme_changed', handler)
Unregisters a previously registered handler for a specific event type.
eventType
: The type of event being unregistered.callback
: The function being removed from the handlers list.
Events from Mezon to web view
export enum MezonAppEvent {
ThemeChanged = 'theme_changed',
ViewPortChanged = 'viewport_changed',
SetCustomStyle = 'set_custom_style',
ReloadIframe = 'reload_iframe',
}
Events from web view to Mezon
export enum MezonWebViewEvent {
IframeReady = 'iframe_ready',
IframeWillReloaded = 'iframe_will_reload',
}
npm run build