吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1347|回复: 0
收起左侧

[其他转载] 使用sendBeacon 实现关闭窗口调用接口

[复制链接]
往后无期 发表于 2022-3-31 11:30
window.onunload = (e) => {
            _gap_time = new Date().getTime() - _beforeUnload_time;
            if (_gap_time <= 5) {
                var blob = new Blob([JSON.stringify(id)], {
                    type: 'application/json; charset=UTF-8',
                });
                if (id) {
                    console.log('关闭')
                    navigator.sendBeacon("/api/services/app/commonSignature/CancelAuthByUserId", blob)
                }
            }
            else {
                console.log("刷新")
            }
        }
        window.onbeforeunload = (e) => {
            _beforeUnload_time = new Date().getTime()
        }

使用sendBeacon 发起异步请求  
使用blbo将传参方式更换为json

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-9 11:20

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表