Here’s a simple program in JavaScript that can help you find the IP address of the device running the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<html> <head> <title>Find your IP Address using JavaScript</title> <script> // using api.ipify.org to get the public ip address // using JavaScript Fetch API to perform HTTP Request fetch('https://api.ipify.org?format=json') .then(response => response.json()) .then(data => document.getElementById("response").innerHTML = data.ip) .catch(error => console.error(error)); </script> </head> <body> Your Public IP Address is: <span id="response"></span> </body> </html> |
This program uses the