You need to making an ajax call to hostip.info to get the IPAddress.
Refer below sample code.
HTML
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "http://api.hostip.info/get_html.php", false);
xmlhttp.send();
hostipInfo = xmlhttp.responseText.split("\n");
for (i = 0; hostipInfo.length >= i; i++) {
ipAddress = hostipInfo[i].split(":");
if (ipAddress[0] == "IP") {
alert("IPAddress: " + ipAddress[1]);
}
}
};
</script>
</body>
</html>
Reference:
https://copyprogramming.com/howto/javascript-how-to-get-own-ip-address-javascript