There's no way to get your IP address with Javascript only. You'll need to rely on a third party service (or retrieve your IP with on your server and return it in the view where your js code is printed). There's no notion of hosts or ip-addresses in the javascript standard library.
- How to get IP address from JavaScript without third party?
- How to get the IP address of a client in JavaScript?
- How to get client IP address and client machine name using JavaScript?
- How do I find the IP address of my client?
How to get IP address from JavaScript without third party?
You cannot get the IP of the machine in JS. Also note that it's not possible to get the IP of the machine on its local domain. It's only possible to use a server-side IP lookup and those will only go the the first external source of the client network, which is generally either the router or the ISP server.
How to get the IP address of a client in JavaScript?
To get the client's public IP address, JavaScript acts as a third-party server-side language. JavaScript can't do it alone, so, jQuery is added to do this. JavaScript works with third-party applications to fetch the IP addresses.
How to get client IP address and client machine name using JavaScript?
There is no way to do so, as JavaScript does not have an access to computer name, file system and other local info. Security is the main purpose. Save this answer. Show activity on this post.
How do I find the IP address of my client?
Determining IP Address using $_SERVER Variable Method : There is another way to get the IP Address by using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables. The variable in the $_SERVER array is created by the web server such as apache and those can be used in PHP.