-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
85 lines (71 loc) · 2.09 KB
/
Copy pathindex.html
File metadata and controls
85 lines (71 loc) · 2.09 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mở bằng Chrome</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 2rem;
background: #f0f0f5;
text-align: center;
}
button {
padding: 12px 24px;
font-size: 16px;
background-color: #4285f4;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #3367d6;
}
#message {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<h2>Mở liên kết bằng Chrome</h2>
<button onclick="openInChrome()">Mở bằng Chrome</button>
<div id="message"></div>
<script>
// Kiểm tra có phải Chrome thật không
function isRealChrome() {
const ua = navigator.userAgent;
if (ua.includes("; wv") || ua.includes("Version/4.0")) {
return false;
}
if (ua.includes("Chrome/") && !ua.includes("Edg/") && !ua.includes("OPR/") && !ua.includes("; wv")) {
return true;
}
return false;
}
// Hàm mở liên kết trong Chrome bằng intent
function openInChrome() {
const messageDiv = document.getElementById("message");
let currentUrl = window.location.href;
let strippedUrl = currentUrl.replace(/^https?:\/\//, '');
let intentUrl = `intent://${strippedUrl}#Intent;package=com.android.chrome;scheme=https;end;`;
if (isRealChrome()) {
messageDiv.textContent = "Bạn đã ở trong Chrome rồi";
return;
}
if (confirm("Bạn có muốn mở liên kết này bằng Chrome không?")) {
window.location.href = intentUrl;
} else {
messageDiv.textContent = "Bạn đã chọn không mở trong Chrome.";
}
setTimeout(() => {
window.open(currentUrl, '_blank');
}, 2000);
}
</script>
</body>
</html>