简体   繁体   中英

Getting an IP address without a server side language

I am trying to make a simple website with only HTML & JavaScript. I want to display the visitors IP address on the screen. I tried to search a lot and came to a conclusion that that is not possible through JavaScript and I would have to use some server side scripting language like PHP. However, I don't want to increase the overheads, how can I achieve this without server side programming?

You can't. JavaScript has no access to any API that will give that information other than via an HTTP request.

NO. Javascript, can't access IP Address. You need an API or a PHP/ASP/JSON File on your web Server. Try this service

<script src="http://www.codehelper.io/api/ips/?js"></script>
<script>
alert(codehelper_ip.IP);
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM