I need to somehow retrieve the client's IP address using JavaScript; no server side code, not even SSI.
However, I'm not against using a free 3rd party script/service.
Java Script to find IP
To get the IP Address I am making a JSON call to the Free Web Service. like
[jsonip.com/json, ipinfo.io/json, www.telize.com/geoip, ip-api.com/json, api.hostip.info/get_json.php]
and I am passing the name of the callback function which will be called on completion of the request.
<script type="text/javascript">
window.onload = function () {
var webService = "http://www.telize.com/geoip";
var script = document.createElement("script");
script.type = "text/javascript";
script.src = webService+"?callback=MyIP";
document.getElementsByTagName("head")[0].appendChild(script);
};
function MyIP(response) {
document.getElementById("ipaddress").innerHTML = "Your IP Address is " + response.ip;
}
</script>
<body>
<form>
<span id = "ipaddress"></span>
</form>
</body>
for xml response code
WebRTC which doesn't require server support.