Below given codes will display the Public IP address of the site visitor or who wants to know the public IP of them.
Here I am using ipapi 's free API plan to grab the IP address and further information on Geolocation.
Once you input this code below output you able to see on the webpage.
Modify the Attributes by following the below section of code.
// Setting text of element P with id ipp
$("#ipp").html(data.ip);
$("#ipversion").html(data.version);
$("#ccity").html(data.city);
$("#cregion").html(data.region);
$("#country").html(data.country_name);
})
</script>
<center>
<h1><b><p id="ipp"></p></b></h1>
<h4>IP Version:<p id="ipversion"></p></h4>
<h4>City:<p id="ccity"></p></h4>
<h4>Region:<p id="cregion"></p></h4>
<h4>Country:<p id="country"></p></h4>
</center>
$("#ipp").html(data.ip);
$("#ipversion").html(data.version);
$("#ccity").html(data.city);
$("#cregion").html(data.region);
$("#country").html(data.country_name);
})
</script>
<center>
<h1><b><p id="ipp"></p></b></h1>
<h4>IP Version:<p id="ipversion"></p></h4>
<h4>City:<p id="ccity"></p></h4>
<h4>Region:<p id="cregion"></p></h4>
<h4>Country:<p id="country"></p></h4>
</center>
Comments
Post a Comment