# Implementing WeChat’s Floating Window Interactions on the Web
# Implementing WeChat’s Floating Window Interactions on the Web by zhangxinxu, from http://www.zhangxinxu.com/wordpress/?p=7662 This article may be reproduced in full, provided that both the original author and the source are credited. ## 1. WeChat’s Floating Window Interactions...
Code: Dispatching a CustomEvent
const event = new CustomEvent('show', {
detail: { message: payload, sentAt: new Date().toLocaleTimeString() }
});
window.dispatchEvent(event);
Result
Waiting for an event...
Code: Listening for the Event Payload
window.addEventListener('show', (event) => {
render(event.detail.message, event.detail.sentAt);
});
Event log
No events yet.