我需要以某种方式使用JavaScript检索客户端的IP地址; 没有服务器端代码,甚至没有SSI。

但是,我不反对使用免费的第三方脚本/服务。


#1楼

在您的页面中包含以下代码: <script type="text/javascript" src="http://l2.io/ip.js"></script>

更多文档在这里


#2楼

我将提供一种方法,当我想在html页面中存储信息时,我会使用很多方法,并且希望我的javascript读取信息而无需实际将参数传递给javascript。 当您的脚本是外部引用而不是内联引用时,这特别有用。

但是,它不符合“没有服务器端脚本”的标准。 但是,如果您可以在HTML中包含服务器端脚本,请执行以下操作:

在html页面底部的end body标签上方制作隐藏的标签元素。

您的标签将如下所示:

<label id="ip" class="hiddenlabel"><?php echo $_SERVER['REMOTE_ADDR']; ?></label>

确保创建一个名为hiddenlabel的类并设置hiddenlabel visibility:hidden这样实际上没有人看到该标签。 您可以通过这种方式在隐藏标签中存储很多东西。

现在,在您的JavaScript中,要检索存储在标签中的信息(在本例中为客户端的IP地址),可以执行以下操作:

var ip = document.getElementById("ip").innerHTML;

现在,您的变量“ ip”等于IP地址。 现在,您可以将ip传递给您的API请求。

*编辑2年后*两个小改进:

我通常使用此方法,但是将其称为标签class="data" ,因为实际上,这是一种存储数据的方法。 类名“ hiddenlabel”是一种愚蠢的名字。

第二个修改是在样式表中,而不是visibility:hidden

.data{display:none;
}

...是更好的方法


#3楼

我想说乍得和马耳他有很好的答案。 但是,它们很复杂。 因此,我建议我根据国家/地区插件从广告中找到的这段代码

<script>
<script language="javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="javascript">
mmjsCountryCode = geoip_country_code();
mmjsCountryName = geoip_country_name();</script>

没有阿贾克斯 只是普通的javascript。 :D

如果您访问http://j.maxmind.com/app/geoip.js ,则会看到其中包含

function geoip_country_code() { return 'ID'; }
function geoip_country_name() { return 'Indonesia'; }
function geoip_city()         { return 'Jakarta'; }
function geoip_region()       { return '04'; }
function geoip_region_name()  { return 'Jakarta Raya'; }
function geoip_latitude()     { return '-6.1744'; }
function geoip_longitude()    { return '106.8294'; }
function geoip_postal_code()  { return ''; }
function geoip_area_code()    { return ''; }
function geoip_metro_code()   { return ''; }

它还没有真正回答问题,因为

http://j.maxmind.com/app/geoip.js不包含IP(尽管我敢打赌它使用IP来获取国家/地区)。

但是,制作弹出类似以下内容的PhP脚本非常容易

function visitorsIP()   { return '123.123.123.123'; }

做那个。 放在http://yourdomain.com/yourip.php上 。

然后做

<script language="javascript" src="http://yourdomain.com/yourip.php"></script>

这个问题专门提到不要使用第三方脚本。 没有别的办法了。 Javascript无法识别您的IP。 但是可以通过javascript访问的其他服务器也可以正常工作。


#4楼

Javascript / jQuery获取客户的IP地址和位置 (国家/地区,城市)

您只需要将带有“ src”链接的标签嵌入服务器。 服务器将返回“ codehelper_ip”作为对象/ JSON,您可以立即使用它。

// First, embed this script in your head or at bottom of the page.
<script language="Javascript" src="http://www.codehelper.io/api/ips/?js"></script>
// You can use it
<script language="Javascript">alert(codehelper_ip.IP);alert(codehelper_ip.Country);
</script>

有关更多信息,请参见Javascript Detect Real IP Address Plus Country

如果您使用的是jQUery,则可以尝试:

console.log(codehelper_ip);

它将向您显示有关返回对象的更多信息。

如果您想要回调函数,请尝试以下操作:

// First, embed this script in your head or at bottom of the page.
<script language="Javascript" src="http://www.codehelper.io/api/ips/?callback=yourcallback"></script>
// You can use it
<script language="Javascript">function yourcallback(json) {alert(json.IP);}
</script>

#5楼

您可以为此使用我的服务http://ipinfo.io ,它将为您提供客户端IP,主机名,地理位置信息和网络所有者。 这是一个记录IP的简单示例:

$.get("http://ipinfo.io", function(response) {console.log(response.ip);
}, "jsonp");

这是一个更详细的JSFiddle示例,该示例还打印了完整的响应信息,因此您可以看到所有可用的详细信息: http : //jsfiddle.net/zK5FN/2/


#6楼

尝试这个

$.get("http://ipinfo.io", function(response) {alert(response.ip);
}, "jsonp");

要么

$(document).ready(function () {$.getJSON("http://jsonip.com/?callback=?", function (data) {console.log(data);alert(data.ip);});
});

小提琴


#7楼

如果不包含文件,则可以执行一个简单的ajax get:

function ip_callback() {$.get("ajax.getIp.php",function(data){ return data; }
}

ajax.getIp.php将是这样的:

<?=$_SERVER['REMOTE_ADDR']?>

#8楼

<!DOCTYPE html>
<html ng-app="getIp">
<body><div ng-controller="getIpCtrl"><div ng-bind="ip"></div></div><!-- Javascript for load faster================================================== --><script src="lib/jquery/jquery.js"></script><script src="lib/angular/angular.min.js"></script><script>/// Scripts app'use strict';/* App Module */var getIp = angular.module('getIp', [ ]);getIp.controller('getIpCtrl', ['$scope', '$http',function($scope, $http) {$http.jsonp('http://jsonip.appspot.com/?callback=JSON_CALLBACK').success(function(data) {$scope.ip = data.ip;});}]);</script>
</body>
</html>

#9楼

Appspot.com回调的服务不可用。 ipinfo.io似乎正在运行。

我做了一个额外的步骤,并使用AngularJS检索了所有地理信息。 (感谢里卡多)看看。

<div ng-controller="geoCtrl"><p ng-bind="ip"></p><p ng-bind="hostname"></p><p ng-bind="loc"></p><p ng-bind="org"></p><p ng-bind="city"></p><p ng-bind="region"></p><p ng-bind="country"></p><p ng-bind="phone"></p>
</div>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular-route.min.js"></script>
<script>
'use strict';
var geo = angular.module('geo', [])
.controller('geoCtrl', ['$scope', '$http', function($scope, $http) {$http.jsonp('http://ipinfo.io/?callback=JSON_CALLBACK').success(function(data) {$scope.ip = data.ip;$scope.hostname = data.hostname;$scope.loc = data.loc; //Latitude and Longitude$scope.org = data.org; //organization$scope.city = data.city;$scope.region = data.region; //state$scope.country = data.country;$scope.phone = data.phone; //city area code});
}]);
</script>

此处的工作页面: http : //www.orangecountyseomarketing.com/projects/_ip_angularjs.html


#10楼

var call_to = "http://smart-ip.net/geoip-json?callback=?";$.getJSON(call_to, function(data){alert(data.host);
});

data.host是IP地址。 只需从浏览器调用即可。

http://smart-ip.net/geoip-json?callback=? [无引号]并获取IP。


#11楼

使用jQuery获取IP

您可以使用一行JS获得您的公共IP地址? 有一项免费服务可以为您提供此服务,并且您需要做的就是获取请求:

   $.get('http://jsonip.com/', function(r){ console.log(r.ip); });

为了使以上代码段起作用,您的浏览器将必须支持CORS(跨域请求共享)。 否则会引发安全异常。 在较旧的浏览器中,可以使用此版本,该版本使用JSON-P请求:

   $.getJSON('http://jsonip.com/?callback=?', function(r){ console.log(r.ip); });

#12楼

您可以使用以下Web服务: http : //ip-api.com/

例:

<script type="text/javascript" src="http://ip-api.com/json/?callback=foo">
<script>function foo(json) {alert(json.query)}
</script>additional example: http://whatmyip.info

#13楼

您可以使用客户端可以调用的Flash对象完全在客户端执行此操作,并且大多数情况下可以在JavaScript中执行此操作。 Flash 可以访问本地计算机的IP地址,该地址可能不是很有用。


#14楼

您可以使用userinfo.io javascript库。

<script type="text/javascript" src="userinfo.0.0.1.min.js"></script>UserInfo.getInfo(function(data) {alert(data.ip_address);
}, function(err) {// Do something with the error
});

您还可以使用requirejs加载脚本。

它会为您提供访问者的IP地址,以及有关其位置(国家,城市等)的一些数据。 它基于maxmind geoip数据库。

免责声明:我写了这个库


#15楼

别再看了

查看http://www.ipify.org/

根据他们:

  • 您可以无限制使用它(即使您每分钟执行数百万个请求)。
  • ipify是完全开源的(请查看GitHub存储库 )。

这是一个有效的JS示例(而不是想知道为什么这个答案投票这么少,请自己尝试一下以查看实际效果):

<script>
function getIP(json) {alert("My public IP address is: " + json.ip);
}
</script>
<script src="https://api.ipify.org?format=jsonp&callback=getIP"></script>

太懒于复制/粘贴? 我喜欢。 这是一个演示

懒得点击? :O

注意在运行演示之前 关闭Adblock Plus / uBlock&co ..否则,它将无法正常工作。

我与IPify团队无关 。 我只是认为有人为一般利益提供这样的服务真是太荒谬了。


#16楼

你不能 您必须询问服务器。


#17楼

最终更新

此解决方案将不再起作用,因为浏览器正在修复webrtc泄漏:有关该问题的更多信息,请阅读另一个问题: RTCIceCandidate不再返回IP


更新 :我一直想做一个最小/丑陋的代码版本,所以这是一个ES6 Promise代码:

 var findIP = new Promise(r=>{var w=window,a=new (w.RTCPeerConnection||w.mozRTCPeerConnection||w.webkitRTCPeerConnection)({iceServers:[]}),b=()=>{};a.createDataChannel("");a.createOffer(c=>a.setLocalDescription(c,b,b),b);a.onicecandidate=c=>{try{c.candidate.candidate.match(/([0-9]{1,3}(\\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g).forEach(r)}catch(e){}}}) /*Usage example*/ findIP.then(ip => document.write('your ip: ', ip)).catch(e => console.error(e)) 

注意:如果您希望用户的所有IP(取决于用户网络的更多IP),请使用原始代码,这个新的压缩代码将仅返回单个IP ...


多亏了WebRTC ,在支持WebRTC的浏览器中很容易获得本地IP(至少现在如此)。 我已经修改了源代码,减少了行数,没有发出任何眩晕请求,因为您只需要本地IP,而不是公共IP,下面的代码在最新的Firefox和Chrome中有效,只需运行代码段并检查一下即可:

 function findIP(onNewIP) { // onNewIp - your listener function for new IPs var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome var pc = new myPeerConnection({iceServers: []}), noop = function() {}, localIPs = {}, ipRegex = /([0-9]{1,3}(\\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g, key; function ipIterate(ip) { if (!localIPs[ip]) onNewIP(ip); localIPs[ip] = true; } pc.createDataChannel(""); //create a bogus data channel pc.createOffer(function(sdp) { sdp.sdp.split('\\n').forEach(function(line) { if (line.indexOf('candidate') < 0) return; line.match(ipRegex).forEach(ipIterate); }); pc.setLocalDescription(sdp, noop, noop); }, noop); // create offer and set local description pc.onicecandidate = function(ice) { //listen for candidate events if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return; ice.candidate.candidate.match(ipRegex).forEach(ipIterate); }; } var ul = document.createElement('ul'); ul.textContent = 'Your IPs are: ' document.body.appendChild(ul); function addIP(ip) { console.log('got ip: ', ip); var li = document.createElement('li'); li.textContent = ip; ul.appendChild(li); } findIP(addIP); 
 <h1> Demo retrieving Client IP using WebRTC </h1> 

这里发生的是,我们正在创建一个虚拟对等连接,并且为了使远程对等体与我们联系,我们通常会相互交换ice候选对象。 并从本地会话描述和onIceCandidateEvent中读取ice候选对象,我们可以告诉用户IP。

我从-> 源代码获取代码的地方


#18楼

有一种更简单,免费的方法,它不会要求您的访客获得任何许可。

它包括向http://freegeoip.net/json提交一个非常简单的Ajax POST请求。 接收到位置信息后,您可以使用JSON通过更新页面或重定向到新页面来做出相应的反应。

这是您提交位置信息请求的方式:

jQuery.ajax( { url: '//freegeoip.net/json/', type: 'POST', dataType: 'jsonp',success: function(location) {console.log(location)}
} );

#19楼

我将使用可以返回JSON的Web服务(与jQuery一起使事情变得更简单)。 以下是我可以找到的所有免费的活动 IP查找服务以及它们返回的信息。 如果您知道更多信息,请添加评论,我将更新此答案。


数据库IP

尝试一下: http : //api.db-ip.com/addrinfo?api_key= < 您的api密钥 >&addr = < IP地址 >

返回值:

{"address": "116.12.250.1","country": "SG","stateprov": "Central Singapore","city": "Singapore"
}

局限性:

  • 每天2,500个请求
  • 不支持JSONP回调
  • 需要IP地址参数
  • 需要电子邮件地址以获取您的API密钥
  • 免费计划没有SSL(https)

千兆字节

试试看: http : //gd.geobytes.com/GetCityDetails

$.getJSON('http://gd.geobytes.com/GetCityDetails?callback=?', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"geobytesforwarderfor": "","geobytesremoteip": "116.12.250.1","geobytesipaddress": "116.12.250.1","geobytescertainty": "99","geobytesinternet": "SA","geobytescountry": "Saudi Arabia","geobytesregionlocationcode": "SASH","geobytesregion": "Ash Sharqiyah","geobytescode": "SH","geobyteslocationcode": "SASHJUBA","geobytescity": "Jubail","geobytescityid": "13793","geobytesfqcn": "Jubail, SH, Saudi Arabia","geobyteslatitude": "27.004999","geobyteslongitude": "49.660999","geobytescapital": "Riyadh ","geobytestimezone": "+03:00","geobytesnationalitysingular": "Saudi Arabian ","geobytespopulation": "22757092","geobytesnationalityplural": "Saudis","geobytesmapreference": "Middle East ","geobytescurrency": "Saudi Riyal","geobytescurrencycode": "SAR","geobytestitle": "Saudi Arabia"
}

局限性:

  • 每小时16,384个请求
  • 免费计划没有SSL(https)
  • 可能返回错误的位置(我在新加坡,而不是沙特阿拉伯)

GeoIPLookup.io

试试看: https : //json.geoiplookup.io/api

$.getJSON('https://json.geoiplookup.io/api?callback=?', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip": "116.12.250.1","isp": "SGPOST","org": "Singapore Post Ltd","hostname": "116.12.250.1","longitude": "103.807","latitude": "1.29209","postal_code": "","city": "Singapore","country_code": "SG","country_name": "Singapore","continent_code": "AS","region": "Central Singapore","district": "","timezone_name": "Asia\/Singapore","connection_type": "","asn": "AS3758 SingNet","currency_code": "SGD","currency_name": "Singapore Dollar","success": true
}

局限性:

  • 未知

geoPlugin

试试看: http : //www.geoplugin.net/json.gp

$.getJSON('http://www.geoplugin.net/json.gp?jsoncallback=?', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"geoplugin_request": "116.12.250.1","geoplugin_status": 200,"geoplugin_credit": "Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\\'http://www.maxmind.com\\'>http://www.maxmind.com</a>.","geoplugin_city": "Singapore","geoplugin_region": "Singapore (general)","geoplugin_areaCode": "0","geoplugin_dmaCode": "0","geoplugin_countryCode": "SG","geoplugin_countryName": "Singapore","geoplugin_continentCode": "AS","geoplugin_latitude": "1.2931","geoplugin_longitude": "103.855797","geoplugin_regionCode": "00","geoplugin_regionName": "Singapore (general)","geoplugin_currencyCode": "SGD","geoplugin_currencySymbol": "&#36;","geoplugin_currencySymbol_UTF8": "$","geoplugin_currencyConverter": 1.4239
}

局限性:

  • 每分钟120个请求
  • 免费计划没有SSL(https)

黑客目标

尝试一下: https : //api.hackertarget.com/geoip/?q= < IP地址 >

返回值:

IP Address: 116.12.250.1
Country: SG
State: N/A
City: Singapore
Latitude: 1.293100
Longitude: 103.855797

局限性:

  • 每天50个请求
  • 不支持JSONP回调
  • 需要IP地址参数
  • 返回纯文本

ipapi.co

试试看: https : //ipapi.co/json/

$.getJSON('https://ipapi.co/json/', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip": "116.12.250.1","city": "Singapore","region": "Central Singapore Community Development Council","country": "SG","country_name": "Singapore","postal": null,"latitude": 1.2855,"longitude": 103.8565,"timezone": "Asia/Singapore"
}

局限性:

  • 每天1,000个请求
  • 需要SSL(https)

IP-API.com

试试看: http : //ip-api.com/json

$.getJSON('http://ip-api.com/json?callback=?', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"as": "AS3758 SingNet","city": "Singapore","country": "Singapore","countryCode": "SG","isp": "SingNet Pte Ltd","lat": 1.2931,"lon": 103.8558,"org": "Singapore Telecommunications","query": "116.12.250.1","region": "01","regionName": "Central Singapore Community Development Council","status": "success","timezone": "Asia/Singapore","zip": ""
}

局限性:

  • 每分钟150个请求
  • 免费计划没有SSL(https)

ipdata.co

试试看: https : //api.ipdata.co

$.getJSON('https://api.ipdata.co', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip": "116.12.250.1","city": "Singapore","region": "Central Singapore Community Development Council","region_code": "01","country_name": "Singapore","country_code": "SG","continent_name": "Asia","continent_code": "AS","latitude": 1.2931,"longitude": 103.8558,"asn": "AS3758","organisation": "SingNet","postal": "","calling_code": "65","flag": "https://ipdata.co/flags/sg.png","emoji_flag": "\ud83c\uddf8\ud83c\uddec","emoji_unicode": "U+1F1F8 U+1F1EC","is_eu": false,"languages": [{"name": "English","native": "English"},{"name": "Malay","native": "Bahasa Melayu"},{"name": "Tamil","native": "\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"},{"name": "Chinese","native": "\u4e2d\u6587"}],"currency": {"name": "Singapore Dollar","code": "SGD","symbol": "S$","native": "$","plural": "Singapore dollars"},"time_zone": {"name": "Asia/Singapore","abbr": "+08","offset": "+0800","is_dst": false,"current_time": "2018-05-09T12:28:49.183674+08:00"},"threat": {"is_tor": false,"is_proxy": false,"is_anonymous": false,"is_known_attacker": false,"is_known_abuser": false,"is_threat": false,"is_bogon": false}
}

局限性:

  • 每天1,500个请求
  • 需要电子邮件地址以获取您的API密钥
  • 需要SSL(https)

IP查找

尝试: https : //ipfind.co/me? auth = < 您的api密钥 >

$.getJSON('https://ipfind.co/me?auth=<your_api_key>', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip_address": "116.12.250.1","country": "Singapore","country_code": "SG","continent": "Asia","continent_code": "AS","city": "Singapore","county": null,"region": "Central Singapore","region_code": "01","timezone": "Asia/Singapore","owner": null,"longitude": 103.8565,"latitude": 1.2855,"currency": "SGD","languages": ["cmn","en-SG","ms-SG","ta-SG","zh-SG"]
}

局限性:

  • 每天300个请求
  • 需要注册才能获取您的API密钥

ipgeolocation

尝试: https : //api.ipgeolocation.io/ipgeo? apiKey = < 您的api密钥 >

$.getJSON('https://api.ipgeolocation.io/ipgeo?apiKey=<your_api_key>', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip": "116.12.250.1","continent_code": "AS","continent_name": "Asia","country_code2": "SG","country_code3": "SGP","country_name": "Singapore","country_capital": "Singapore","state_prov": "Central Singapore","district": "","city": "Singapore","zipcode": "","latitude": "1.29209","longitude": "103.807","is_eu": false,"calling_code": "+65","country_tld": ".sg","languages": "cmn,en-SG,ms-SG,ta-SG,zh-SG","country_flag": "https://ipgeolocation.io/static/flags/sg_64.png","isp": "SGPOST","connection_type": "","organization": "Singapore Post Ltd","geoname_id": "1880252","currency": {"name": "Dollar","code": "SGD"},"time_zone": {"name": "Asia/Singapore","offset": 8,"is_dst": false,"current_time": "2018-06-12 09:06:49.028+0800"}
}

局限性:

  • 每月50,000个请求
  • 需要注册才能获取您的API密钥

ipify

试试看: https : //api.ipify.org/?format=json

$.getJSON('https://api.ipify.org?format=jsonp&callback=?', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip": "116.12.250.1"
}

局限性:

  • 没有

IP信息数据库

尝试: https : //api.ipinfodb.com/v3/ip-city/?key = < 您的api密钥 >&format = json

$.getJSON('https://api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&format=json&callback=?', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"statusCode": "OK","statusMessage": "","ipAddress": "116.12.250.1","countryCode": "SG","countryName": "Singapore","regionName": "Singapore","cityName": "Singapore","zipCode": "048941","latitude": "1.28967","longitude": "103.85","timeZone": "+08:00"
}

局限性:

  • 每秒两个请求
  • 需要注册才能获取您的API密钥

ipinfo.io

试试看: https : //ipinfo.io/json

$.getJSON('https://ipinfo.io/json', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip": "116.12.250.1","hostname": "No Hostname","city": "Singapore","region": "Central Singapore Community Development Council","country": "SG","loc": "1.2931,103.8558","org": "AS3758 SingNet"
}

局限性:

  • 每天1,000个请求

帝国主义

尝试: https : //api.ipregistry.co/?key = < 您的api密钥 >

$.getJSON('https://api.ipregistry.co/?key=<your_api_key>', function(data) {console.log(JSON.stringify(data, null, 2));
});

返回值:

{"ip" : "116.12.250.1","type" : "IPv4","hostname" : null,"carrier" : {"name" : null,"mcc" : null,"mnc" : null},"connection" : {"asn" : 3758,"domain" : "singnet.com.sg","organization" : "SingNet Pte Ltd","type" : "isp"},"currency" : {"code" : "SGD","name" : "Singapore Dollar","plural" : "Singapore dollars","symbol" : "SGD","symbol_native" : "SGD","format" : {"negative" : {"prefix" : "-SGD","suffix" : ""},"positive" : {"prefix" : "SGD","suffix" : ""}}},"location" : {"continent" : {"code" : "AS","name" : "Asia"},"country" : {"area" : 692.0,"borders" : [ ],"calling_code" : "65","capital" : "Singapore","code" : "SG","name" : "Singapore","population" : 5638676,"population_density" : 8148.38,"flag" : {"emoji" : "												

如何使用JavaScript获取客户端的IP地址?相关推荐

  1. 使用JS获取客户端的IP地址

    使用JS获取客户端的IP地址 搜狐IP地址查询接口(可设置编码):https://pv.sohu.com/cityjson?ie=utf-8 简单使用: <script src="ht ...

  2. 在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr() ,这种方法在大部分情况下都是有效的。但是在通过了Apache,Squi...

    在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr() ,这种方法在大部分情况下都是有效的.但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实 ...

  3. 获取客户端的IP地址

    #region public static string GetClientIP() 获取客户端的IP地址/// <summary>/// 获取客户端的IP地址/// </summa ...

  4. php如何获取客户端请求ip地址的方法

    php如何获取客户端请求ip地址的方法 获取客户端ip地址的函数 获取客户端ip地址的函数 function getip(){$ip = false;if (!empty($_SERVER[" ...

  5. java获取客户端的IP地址工具类

    java获取客户端的IP地址工具类 import java.net.InetAddress; import java.net.UnknownHostException;import javax.ser ...

  6. PHP获取客户端真实IP地址的方法

    php获取客户端IP地址有四种方法,这五种方法分别为 1 2 3 4 REMOTE_ADDR HTTP_CLIENT_IP HTTP_X_FORWARDED_FOR HTTP_VIA REMOTE_A ...

  7. 关于如何通过IE浏览器获取客户端的IP地址和Mac地址

    在项目开发中,我们经常会使用到客户端的IP地址.Mac地址和电脑名,下面争对IE浏览器获取IP,Mac和电能名的方法: 需要注意的是,要设置IE浏览器能够加载ActiveX控件,否则会组织获取到相关的 ...

  8. java获取客户端请求IP地址 获取公网ip

    这几天搞了用java获取ip地址,由于测试方法不对,一直没有成功,昨天终于想通了并不是方法不对,而是我的测试方法不对,下面这个方法,完全可以得到客户端的公网ip地址 但是在测试的时候注意:我用的是we ...

  9. 获取客户端真实IP地址

    Java-Web获取客户端真实IP: 发生的场景:服务器端接收客户端请求的时候,一般需要进行签名验证,客户端IP限定等情况,在进行客户端IP限定的时候,需要首先获取该真实的IP. 一般分为两种情况: ...

最新文章

  1. 1、在Centos上安装Grafana
  2. 使用Minify合并css和js减少http请求
  3. 从Asp.net转到Php之调试
  4. 有关无人驾驶汽车的思考
  5. altium如何制作mark点_如何选择一家优质的网站制作公司,看这2点
  6. java代码连接redis_java代码连接redis
  7. Oracle的列转行问题
  8. 完成端口(CompletionPort)之客户端篇
  9. c++ Simpson积分
  10. 80老翁谈人生(314):别了,亲爱的CSDN读者朋友们!
  11. 支付机构客户备付金存管办法
  12. HTML——表格table
  13. 简单实现B/S服务器
  14. 一直在构建工作空间_国土空间规划一周知识整理(2020.11.09-2020.11.15)
  15. Ubuntu 16.04安装的一些基础软件--搜狗输入法、Chrome、网易云音乐、sublime text
  16. 【杂货铺】金融机构分类
  17. 德州扑克多个玩家对局时赢牌牌型概率分布表、各种牌型的出现概率
  18. 木筏求生1.0.0游戏
  19. Android 11整合Mopria联盟的代码贡献以实现增强的打印功能
  20. 五年,他们从应届生成为了滴滴的「技术扛把子」

热门文章

  1. 不同版本的nutz与log4j2的集成方法
  2. lazy load 图片延迟加载 跟随滚动条
  3. 一生要做的九十九件事
  4. html5利用websocket完成的推送功能
  5. [Python]从哪里开始学习写代码(未完待续)
  6. Mybatis原理分析之二:框架整体设计
  7. cojs 安科赛斯特 题解报告
  8. Notepad++ 配置java编译环境
  9. python基础—正则表达式即re模块
  10. zabbix4.2-zabbix自动发现规则