-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtxjc.js
More file actions
40 lines (32 loc) · 1.45 KB
/
Copy pathtxjc.js
File metadata and controls
40 lines (32 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//重写某讯环境检测
(function() {
// 获取查询参数redirect的值
var urlParams = new URLSearchParams(window.location.search);
var redirectUrl = urlParams.get('redirect');
var isWeixin = /MicroMessenger/i.test(navigator.userAgent);
var isQQBrowser = /QQBrowser/i.test(navigator.userAgent);
var isQQ = /QQ/i.test(navigator.userAgent);
var isQZone = /Qzone/i.test(navigator.userAgent);
var isTM = /TencentTraveler/i.test(navigator.userAgent);
if (redirectUrl !== null && redirectUrl !== '') {
// 如果存在redirect参数值且不等于空
if (isWeixin || isQQBrowser || isQQ || isQZone || isTM) {
//还在tx环境中,继续打开带参数页面无动作
}else {
//在第三方浏览器,打开解析出的原始页面
window.location.href = redirectUrl;
}
} else {
if (isWeixin || isQQBrowser || isQQ || isQZone || isTM) {
// 如果不存在redirect参数值或为空,代表首次在tx环境
// 获取当前页面的URL
var currentUrl = window.location.href;
// 构建跳转URL
var redirectUrl = "https://eazyfun.github.io/js/?redirect=" + currentUrl;
// 跳转到提示页面,并附带原页面URL作为参数
window.location.href = redirectUrl;
}else {
//在第三方浏览器,无需动作
}
}
})();