问题
I'm looking for a solution to grab people's internal ip addresses in IE (not using java or java applets). The equivalent in Java looks like that:
this.sock.bind(new java.net.InetSocketAddress('0.0.0.0', 0));
this.sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port)?80:document.location.port));
return this.sock.getLocalAddress().getHostAddress();
Is that something possible in vbscript or jscript? Could you provide me with an example?
Thanks for your time.
回答1:
You can not get internal IP with JavaScript.
This looks like something you'll need an ActiveX control for, if it is possible.
回答2:
I think that depending on the security settings in IE you might be able to use WMI. If so you could just use the Win32_NetworkAdapterConfiguration and it's IPAddress
property.
The following sample in vbscript:
strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfiguration ")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) _
to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
Is taken from this MSDN page.
来源:https://stackoverflow.com/questions/4241591/internet-explorer-grab-internal-ip-address