how to send an end event beforeunload?
See original GitHub issueI want to send an end event like this:
window.addEventListener('unload',() => {
store.dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'EndOfConversation'
}
});
});
but it didn’t work for me. As i know,unload will block xhr request,is there other way to resolve this problem?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Window: beforeunload event - Web APIs | MDN
The beforeunload event is fired when the window, the document and its resources are about to be unloaded. The document is still visible...
Read more >How to Send an Asynchronous Request at the End of a Page ...
First, we might think of the beforeunload event. It enables the web page to trigger a confirmation dialog to ask the user if...
Read more >Sure you want to leave?—browser beforeunload event
In the video, I explain a bit about the beforeunload event—which lets you prompt or warn your user that they're about to leave...
Read more >unload And beforeunload Events And How To Debug Them ...
So I set a breakpoint where the code that is supposed to be fired by the unload event is, and reloaded the page...
Read more >How to call a function before leaving page with Javascript
The short answer is you can't do this. The onbeforeunload event can only be used to trigger that popup, it can't be used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zp1112, I have found the following to work for me. Place it in your page where the Web Chat store is accessible. In my case, I’m persisting conversations which is how I’m able to see the posted message in Web Chat.
I can’t say that it will work in every situation for every browser or version (I’m using Chrome and have run successfully on a multitude of versions), but it’s a jumping off point, at least. @compulim could speak more to that, if more is needed to be said than what he posted above.
Message received by bot
Web Chat activity
Hope of help!!
this method doesn’t work. yes the message is added to the chat window, but newest version of chrome disables the request. “Send failure” is the result.