复制代码代码如下:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/htmlcharset=gbk">
</head>
<body>
<object classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" id="locator" style="display:nonevisibility:hidden"></object>
<object classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223" id="foo" style="display:nonevisibility:hidden"></object>
<form name="myForm">
<br/>MAC地址:<input type="text" name="macAddress">
<br/>IP地址:<input type="text" name="ipAddress">
<br/>主机名:<input type="text" name="hostName">
</form>
</body>
</html>
<script language="javascript">
var sMacAddr=""
var sIPAddr=""
var sDNSName=""
var service = locator.ConnectServer()
service.Security_.ImpersonationLevel=3
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration')
</script>
<script FOR="foo" EVENT="OnObjectReady(objObject,objAsyncContext)" LANGUAGE="JScript">
if(objObject.IPEnabled != null &&objObject.IPEnabled != "undefined" &&objObject.IPEnabled == true){
if(objObject.IPEnabled &&objObject.IPAddress(0) !=null &&objObject.IPAddress(0) != "undefined")
sIPAddr = objObject.IPAddress(0)
if(objObject.MACAddress != null &&objObject.MACAddress != "undefined")
sMacAddr = objObject.MACAddress
if(objObject.DNSHostName != null &&objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName
}
</script>
<script FOR="foo" EVENT="OnCompleted(hResult,pErrorObject, pAsyncContext)" LANGUAGE="JScript">
myForm.macAddress.value=sMacAddr
myForm.ipAddress.value=sIPAddr
myForm.hostName.value=sDNSName
</script>
获取地址栏参数值http://www.xxx.com/index.html?ver=1.0&id=6#page1
getQueryVariable(ver)// 1.0
getQueryVariable(id) // 6
我们可以用javascript获得其中的各个部分
1、整个URl字符串(在浏览器中就是完整的地址栏 http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
本例返回值: ( http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
2、URL 的协议部分 ( http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
本例返回值:http:
3、URL 的主机部分 ( http://www.xxx.com/index.html?ver=1.0&id=6#page1 )
本例返回值: www.xxx.com
4、URL 的端口部分 ( http:192.168.1.152:8080/index.html)
如果采用默认的80端口(update:即使添加了:80),那么返回值并不是默认的80而是空字符
本例返回值:"8080"
5、URL 的路径部分( http://192.168.1.145/community/page/index.html?categoryId=#page3 )
本例返回值:/community/page/index.html
6、查询(参数)部分
除了给动态语言赋值以外,我们同样可以给静态页面,并使用javascript来获得相信应的参数值
本例返回值:?ver=1.0&id=6
7、锚点 ( http://192.168.1.145/community/page/index.html?categoryId=#page3 )
本例返回值:#page3