To get the IP of the javascript user is possible to use any site, I recommend using the api ipify.
https://www.ipify.org
Use the Jquery version code it is quite easy that normal javascript, put it in your head first:
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
Put this exactly into your script element to run it, do a small test first. requires an updated or old Jquery version.
$(function() {
$.getJSON("https://api.ipify.org?format=jsonp&callback=?",
function(json) {
document.write("Meu IP público é: ", json.ip);
}
);
});
Feel free to test the script with what I put below. Remember, the api site is a little slow I think so... it may take about 15 seconds for the IP to be updated, obviously depends on your internet.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<html>
<head>
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
<script type="application/javascript">
$(function() {
$.getJSON("https://api.ipify.org?format=jsonp&callback=?",
function(json) {
document.write("Meu IP público é: ", json.ip);
}
);
});
</script>
</head>
<body>
</body>
</html>
What are the three commands?
– BrTkCa