Get Client IP using JavaScript, JQuery
0 5848
An IP address stands for Internet Protocol address is a unique address (unique identifier) that identifies a device on the Internet or a local network. All devices that are connected to an internet connection have a unique IP address.
An IP address looks like 180.100.90.111.
There are two IP versions: IPv4 and IPv6.
IPv4 is the older version and IPv6 is the new version. There are 4 types of IP addresses like private IP addresses, public IP addresses, static IP addresses, and dynamic IP addresses.
To get the client public IP address, JavaScript needs third party server-side language. JavaScript cannot do it alone so jQuery is added must do this. JavaScript works with third-party applications to fetch the IP addresses.
Check My IP Address
Here, we will be using ipify popular tools for finding IP addresses.
Program:
<!DOCTYPE html> <html> <head> <title>Getting Clients IP Using Javascript, JQuery</title> <style> p, h1 { color: red; } </style> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> </script> <script> /* Add "https://api.ipify.org?format=json" */ $.getJSON("https://api.ipify.org?format=json", function(data) { $("#GettoIP").html(data.ip); }) </script> </head> <body> <center> <h1>Coding Tag</h1> <h3>Public IP Address of Current user is:</h3> <p id="GettoIP"></p> </center> </body> </html>
Share:
Comments
Waiting for your comments