JS get the network IP address of this machine

Source: Internet
Author: User
Tags get ip

JavaScript is a scripting language that can't manipulate files and read local information, so you want to get IP, and you need back-end technology. Here's how:

//获取本机的网络ip地址function jsonpCallback(res) {    var ip = res.Ip;    // ip地址    var aa = res.Isp.split("市");    var isp = aa[0];    // ip省份    alert(ip);}function getIntnetIP() {    var JSONP=document.createElement("script");    JSONP.type="text/javascript";    JSONP.src="http://chaxun.1616.net/s.php?type=ip&v=&output=json&callback=jsonpCallback";    document.getElementsByTagName("head")[0].appendChild(JSONP);}getIntnetIP();

The implementation principle is to access a network address, through the backend to get to your network IP, back to the front end.

JS get the network IP address of this machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.