screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <title>Get IP Address</title> </head> <body> <h1>Javascript Current IP Address</h1> <p>Current IP address is: <span id="ip-address"></span></p> <script> window.addEventListener('DOMContentLoaded', getIPAddress); function getIPAddress() { fetch('https://api.ipify.org?format=json') .then(response => response.json()) .then(data => { const ipAddress = data.ip; document.getElementById('ip-address').textContent = ipAddress; }) .catch(error => { console.error('Error:', error); }); } </script> </body> </html>