以下は、JSによるURLアドレスを取得するいくつかの方法です
コードコピーは次のとおりです。
thisurl = document.url;
thishref = document.location.href;
thissloc = self.location.href;
thisdloc = document.location;
thistloc = top.location.href;
thisploc = parent.document.location;
thisthost = top.location.hostname;
thishost = location.hostname;
tmphpage = thishref.split( "/");
thishpage = tmphpage [tmphpage.length-1];
tmpupage = thisurl.split( "/");
thisupage = tmpupage [tmpupage.length-1];
以下は、JSを使用してMACアドレス、IPアドレス、ホスト名を取得する方法です。
コードコピーは次のとおりです。
<html>
<head>
<title> </title>
<meta http-equiv = "content-type" content = "text/html; charset = gbk">
</head>
<body>
<object classID = "clsid:76A64158-CB41-11D1-8B02-00600806D9B6" ID = "Locator" style = "display:none; visibility:hidden"> </object>
<object classId = "clsid:75718c9a-f029-11d1-a1ac-00c04fb6c223" id = "foo" stiled = "display:none; vivivible:hisdibility:hidden"> </object>
<form name = "myform">
<br/> Macアドレス:<入力型= "Text" name = "macaddress">
<br/> IPアドレス:<入力タイプ= "テキスト" name = "iPaddress">
<br/>ホスト名:<入力タイプ= "テキスト" name = "hostname">
</form>
</body>
</html>
<スクリプト言語= "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)"言語= "jscript">
if(objobject.ipenabled!= null && objobject.ipenabled!= "undefined" && objobject.ipenabled == true){
if(objobject.ipenabled && objobject.ipaddress(0)!= null && objobject.ipaddress!= "undefined")
sipaddr = objobject.ipaddress(0);
if(objobject.macaddress!= null && objobject.macaddress!= "undefined"))
smacaddr = objobject.macaddress;
if(objobject.dnshostname!= null && objobject.dnshostname!= "未定"))
sdnsname = objobject.dnshostname;
}
</script>
<for = "foo" event = "oncompleted(hresult、perrorobject、pasynccontext)" language = "jscript">
myform.macaddress.value = smacaddr;
myform.ipaddress.value = sipaddr;
myform.hostname.value = sdnsname;
</script>