当前位置:网站首页>关闭页面时向后台发送消息
关闭页面时向后台发送消息
2022-07-28 08:03:00 【仲夏你的梦】
语法:
navigator.sendBeacon(url, data);返回值:
当用户代理成功把数据加入传输队列时,sendBeacon() 方法将会返回 true,否则返回 false。
代码:
window.addEventListener("beforeunload", (e) => {
const data = {name: "我是豆豆"};
window.navigator.sendBeacon("http://127.0.0.1:1991/loginout", JSON.stringify(data));
});不管是刷新页面还是关闭页面,后台都能接收到前端发送过来的请求,完美实现需求。
边栏推荐
- Feign调用异常[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = n]
- CSV file storage
- How to obtain the subordinate / annotation information of KEGG channel
- Among China's top ten national snacks, it is actually the first
- Vs2015 use dumpbin to view the exported function symbols of the library
- Oracle SQL problems
- Eight ways to solve EMC and EMI conducted interference
- Go interface advanced
- Digital signatures and Ca certificates
- C #, introductory tutorial -- debugging skills and logical error probe technology and source code when the program is running
猜你喜欢

Go panic and recover

SQL injection - pre Foundation
![Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]](/img/97/6c3662ef36b02bc42eec95abaa6bc5.png)
Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]

49 opencv deep analysis profile

How to obtain the subordinate / annotation information of KEGG channel

DIY system home page, your personalized needs PRO system to meet!

golang 协程的实现原理

TXT文本文件存储

谷歌 Material Design 的文本框为什么没人用?

推荐一个摆脱变量名纠结的神器和批量修改文件名方法
随机推荐
Go waitgroup and defer
Will sqlserver CDC 2.2 generate table locks when extracting large tables from the source
MDM data quality application description
象棋机器人夹伤7岁男孩手指,软件测试工程师的锅?我笑了。。。
Chapter 2-14 sum integer segments
When I use MySQL CDC, there are 100 million pieces of data in the source table. In the full volume phase, when I synchronize 10 million, I stop, and then pass
CSV file storage
Image batch processing | necessary skills
置顶各大平台,22版面试核心知识解析笔记,强势上榜
剑指offer
Baidu AI Cloud Jiuzhou district and county brain, depicting a new blueprint for urban and rural areas!
站在大佬的肩膀上,你可以看的更远
Flink Window&Time 原理
Hcip day 8
49 opencv deep analysis profile
Go panic and recover
Detailed explanation of DHCP distribution address of routing / layer 3 switch [Huawei ENSP]
Bluetooth technology | it is reported that apple, meta and other manufacturers will promote new wearable devices, and Bluetooth will help the development of intelligent wearable devices
There is a bug in installing CONDA environment
NDK 系列(6):说一下注册 JNI 函数的方式和时机