当前位置:网站首页>In the closing pages/uninstall (unload) sends a request to the server before the document
In the closing pages/uninstall (unload) sends a request to the server before the document
2022-08-11 04:54:00 【qq_46302247】
Official introduction: https://developer.mozilla.org/zh-CN/docs/Web/API/Navigator/sendBeacon
For reference: https://www.jianshu.com/p/04e88271a8f2?from
Ultimate Solution:
window.addEventListener("beforeunload", (e) => {const data = {name: "tm"};window.navigator.sendBeacon("http://127.0.0.1:1891/loginout", JSON.stringify(data));}); Whether the page is refreshed or closed, the backend can receive the request sent by the frontend, perfectly fulfilling the requirement.
边栏推荐
猜你喜欢
随机推荐
一起Talk编程语言吧
交换机和路由器技术-30-标准ACL
关于数据分页显示
交换机和路由器技术-24-OSPF单区域配置
JVM 垃圾回收的概述与机制
网络协议1
About the pom.xml file
[Web3 series development tutorial - create your first NFT (9)] How to view your NFT in the mobile wallet
Switches and routers technologies - 30 - standard acls
交换机--- 生成树--三层架构总结
Use Navicat Premium to export database table structure information to Excel
About data paging display
Events and scheduled tasks in Mysql
如何缓解压力、拒绝内耗【1】
[Server installation Redis] Centos7 offline installation of redis
剑指offer_抽象建模能力
Optimization is a kind of habit low starting point is the "standing near the critical"
交换机和路由器技术-21-RIP路由协议
[Server installation mysql] Use mysql offline installation package to install mysql5.7 under centos7
[E-commerce operation] How to formulate a social media marketing strategy?









