document.addEventListener("DOMContentLoaded", function() { // Fetch the IP address from the API fetch("https://ipinfo.io/json") .then(response => response.json()) .then(data => { // Display the IP address on the screen document.getElementById("ip").textContent = ` ${data.ip + " " + data.city + " "+ data.region + " " + data.country}`; }) .catch(error => { console.error("Error fetching IP address:", error); document.getElementById("ip-address").textContent = "Unable to retrieve IP address."; }); });