-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThanks.html
More file actions
44 lines (40 loc) · 1.11 KB
/
Thanks.html
File metadata and controls
44 lines (40 loc) · 1.11 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>IP Tracker</title>
</head>
<body>
<div style="text-align: center; margin-top: 50px;">
<h1>Your IP Tracker</h1>
<p id="ip">Loading your IP...</p>
</div>
<script>
// Function to fetch the user's IP address
async function getUserIP() {
try {
// Fetch the IP from ipify API
const res = await fetch('https://api.ipify.org?format=json');
const data = await res.json();
// Return the IP address
return data.ip;
} catch (error) {
console.error("Error fetching IP:", error);
return null;
}
}
// Function to display the IP
async function displayIP() {
const ip = await getUserIP();
if (ip) {
document.getElementById("ip").textContent = `Your IP Address: ${ip}`;
} else {
document.getElementById("ip").textContent = "Unable to fetch your IP.";
}
}
// Call displayIP function when the page loads
displayIP();
</script>
</body>
</html>