I just want to ask, is there a way on how to get ip addresses using javascript only? been searching for quite a while now and most of the results were I need to use api(s). I have used this webrtc and it works great but it's not working on IE, API is great, I've tested some and that works great in different browsers.
but I need to get the code itself from api, or is it possible to get/extract the code from api itself and make a specified file for the source so I won't rely on source from the internet?
I need the RAW file from api, because if ever the src of the api went down, my site will be affected too, so I want it to get and create a external source and include it on my site.
Try following solution :-
First option :-
$(document).ready(function () {
$.getJSON("http://jsonip.com/?callback=?", function (data) {
console.log(data);
alert(data.ip);
});
});
Second option :-
$.get("http://ipinfo.io", function(response) {
alert(response.ip);
}, "jsonp");
It may help you.
I could be wrong, but I think you can only detect the IP serverside, so you'll have to do some kind of a get/post request.
The other answer shows a possible implementation of this.
Also, see this question: How to get client's IP address using javascript only?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With