I don't think you can without some server interaction.
The easiest way would be making an AJAX request to a server-side snippet that, in PHP, would look like this:
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
You can't directly. One approach could be to send an AJAX request to your server (if there is one), which can return the IP address from which the user is viewing the current page.
192.168.x.x (or that other one which I just can't seem to remember)
So put the ip in the page by php, like suggested above, of have a dedicated script echoing just the remote ip. That will then be the ip you have as seen from on the internet.
I think, you can't. But if your server has at least Server Side includes (SSI) - which every apache installation has enabled by default - you can get the ip like this:
var ip = '<!--#echo var="REMOTE_ADDR"-->';
This works on my Mac when embedded in NodeJS code, and gives the local IP address of the server running the code:
Note: 'en0' is the network interface in this case - you may find that your network connection is through 'en1' or 'en2' etc, so you will need to add a bit of logic to find which interface is being used.
Hope this helps
©2020 All rights reserved.