使用新浪接口:(我测试过,此方法好像不行。访问网站也不能访问了。)
个人Robert Hashemian写的:
利用ActiveXObject控件,ie浏览器里要开启此控件:
js获取的ip地址是:自动配置的IPv4地址:<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
<SCRIPT language=JScript>
var service = locator.ConnectServer()
var MACAddr
var IPAddr
var DomainAddr
var sDNSName
service.Security_.ImpersonationLevel=3
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration')
</SCRIPT>
<FORM id=formfoo name=formbar action=NICPost.asp method=post>
<INPUT value=00:05:5D:0E:C7:FA name=txtMACAddr>
<INPUT value=58.245.184.191 name=txtIPAddr >
<INPUT value=typ name=txtDNSName >
</FORM>
/*** 获取本地IP地址
*/
function getLocalIPAddress()
{
var obj = null
var rslt = "127.0.0.1"
try
{
obj = new ActiveXObject("rcbdyctl.Setting")
if (!isNull(obj.GetIPAddress))
{
rslt = obj.GetIPAddress
}
obj = null
}
catch(e)
{
//异常发生
}
return rslt
}