-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
36 lines (32 loc) · 1.03 KB
/
index.html
File metadata and controls
36 lines (32 loc) · 1.03 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
<!DOCTYPE html>
<html>
<head>
<title>App Opener</title>
</head>
<body>
<h1>App Opener</h1>
<ul>
<li><a href="https://youtube.com/@shyambhai420">Open My App</a></li>
<!-- <li><a href="anotherapp://open">Open Another App</a></li> -->
</ul>
<script>
// Function to handle the link click event
function handleAppLink(event) {
event.preventDefault();
var appURL = event.target.href;
// Check if the app is available on the device
if (navigator.userAgent.match(/(iPad|iPhone|iPod|Android)/)) {
window.location = appURL;
} else {
// Redirect to a fallback URL or show an error message
window.location = "https://example.com/app-not-available";
}
}
// Attach the event listener to all app links
var appLinks = document.querySelectorAll('a[href^="myapp://"], a[href^="anotherapp://"]');
appLinks.forEach(function(link) {
link.addEventListener('click', handleAppLink);
});
</script>
</body>
</html>