Im Folgenden finden Sie verschiedene Möglichkeiten, URL -Adressen von JS zu erhalten
Die Codekopie lautet wie folgt:
thisurl = document.url;
thref = document.location.href;
thisSloc = self.location.href;
thisdloc = document.location;
Thistloc = top.location.href;
thisploc = parent.document.location;
thostthost = top.location.hostname;
thisHost = location.hostname;
tmPhPage = thref.Split ("/");
thisHPage = tmphpage [tmphpage.length-1];
tmpupage = thisurl.split ("/");
thisUpage = tmpupage [tmpupage.length-1];
Im Folgenden ist die Methode, um JS zu verwenden, um die MAC -Adresse, die IP -Adresse und den Hostnamen zu erhalten:
Die Codekopie lautet wie folgt:
<html>
<kopf>
<title> </title>
<meta http-äquiv = "content-type" content = "text/html; charset = gbk">
</head>
<body>
<Object ClassID = "CLSID: 76A64158-CB41-11D1-8B02-00600806D9B6" ID = "Locator" style = "Anzeige: Keine; Sichtbarkeit: Hidden"> </Object>
<Object ClassID = "CLSID: 75718C9A-F029-11D1-A1AC-00C04FB6C223" ID = "Foo" style = "Anzeige: Keine; Sichtbarkeit: Hidden"> </Object>
<Formular name = "myForm">
<br/> MAC -Adresse: <Eingabe type = "text" name = "macaddress">
<br/> IP -Adresse: <Eingabe type = "text" name = "ipaddress">
<br/> Hostname: <Eingabe 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 = "OnobJectrady (ObjObject, objasynccontext)" Sprache = "Jscript">
if (objObject.ipenabled! = null && objObject.ipenabled!
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)" Sprache = "Jscript">
myForm.macaddress.Value = Smacaddr;
myForm.ipaddress.Value = sipaddr;
myForm.hostname.Value = sdnsname;
</script>