我需要以某种方式使用JavaScript检索客户端的IP地址; 没有服务器端代码,甚至没有SSI.
但是,我并不反对使用免费的第三方脚本/服务.
刚刚注意到仅在 Chrome 上,RTCIceCandidate 不再返回 IP,而是一个混淆的地址。
RTCIceCandidate
address: "a5b3ef18-2e66-4e24-91d2-893b93bbc1c1.local"
candidate: "candidate:169888242 1 udp 2113937151 a5b3ef18-2e66-4e24-91d2-893b93bbc1c1.local 47871 typ host generation 0 ufrag 7dHv network-cost 999"
component: "rtp"
foundation: "169888242"
port: 47871
priority: 2113937151
protocol: "udp"
relatedAddress: null
relatedPort: null
sdpMLineIndex: 0
sdpMid: "0"
tcpType: ""
type: "host"
usernameFragment: "7dHv"
Run Code Online (Sandbox Code Playgroud)
注意 RTCIceCanadate 的第一个属性是“address”,“ip”不再是这个对象的一部分。
以下代码确定浏览器的本地 IP 地址。仍然适用于 MOZ。
function discover()
{
try{
//Get Local IP
window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
if (pc)
pc.close(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试获取客户端的IP地址.到目前为止这是我的代码.有什么建议?
<script type="application/javascript">
function getIP(json) {
document.write("My public IP address is: ", json.ip);
}
</script>
<script type="application/javascript" src="http://ipinfo.io/?format=jsonp&callback=getIP"></script>Run Code Online (Sandbox Code Playgroud)
我想在 javascript 中获取我机器的 Ip 地址,这在我的 html 页面中进一步引用。我已经参考了所有建议的链接,但没有得到任何答案。我不想使用任何链接来获取 IP,所以我尝试在我的 javascript 中使用以下代码行
var ip = '<%=request.getRemoteAddr();%>';
Run Code Online (Sandbox Code Playgroud)
或者
var ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
var ip = Request.UserHostAddress.ToString();
Run Code Online (Sandbox Code Playgroud)
但是没有得到结果。
请帮我找到解决方案。我想在我的 html 页面中包含这个 javascript,我不想使用任何链接来获取 IP。
All the links I have gone through gives the external links to get the IP address and I do not want to use any external link to get the IP.
我是Vue.js的新手。我需要在Vue.js中获取用户ip地址。
我之前要做的是API内的req.ip,但我的API始终会获得Vue.js服务器IP。
所以我认为Vue.js必须确定用户IP是什么。但是我仍然没有找到在Vue.js中获取用户ip的最佳方法。有人帮忙吗?