In the following blog post, you will learn what is an IP address? and very useful tips on how to get client IP address using JavaScript in Html.
- Keep reading on How to validate Google reCAPTCHA in JavaScript
What is an IP Address?
The “IP” part of the IP address stands for “Internet Protocol”. The “address” part refers to a unique number that gets linked to all online activity you do, somewhat like a return address on a letter you’d send out. There are two primary types of IP address formats used today — IPv4 and IPv6.
Get client IP address using JavaScript
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>javascript get ip address of client</title> <script type="text/javascript"> window.onload = function () { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://api.ipify.org?format=jsonp&callback=DisplayIP"; document.getElementsByTagName("head")[0].appendChild(script); }; function DisplayIP(response) { document.getElementById("ipaddress").innerHTML = "Your IP Address is " + response.ip; } </script> </head> <body> <span id="ipaddress"></span> </body> </html>
Conclusion
I hope you liked this article on how to know IP address using JavaScript. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.
Leave a Reply