Voici plusieurs façons d'obtenir des adresses URL par JS
La copie de code est la suivante:
thisUrl = document.url;
thisHref = document.location.href;
thisSloc = self.location.href;
thisDloc = document.location;
thattloc = top.location.href;
thisPloc = parent.Document.location;
thisThost = top.location.hostname;
thatHost = location.hostname;
tmphPage = thatHref.split ("/");
thatHPage = tmphPage [tmphpage.length-1];
tmpupage = thisUrl.split ("/");
thisupage = tmpupage [tmpupage.length-1];
Ce qui suit est la méthode pour utiliser JS pour obtenir l'adresse MAC, l'adresse IP et le nom d'hôte:
La copie de code est la suivante:
<html>
<adal>
<Title> </Title>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = gbk">
</ head>
<body>
<Object Classid = "CLSID: 76A64158-CB41-11D1-8B02-00600806D9B6" ID = "Locator" Style = "Affichage: Aucun; Visibilité: Hidden"> </ Object>
<Object Classid = "CLSID: 75718C9A-F029-11D1-A1AC-00C04FB6C223" ID = "FOO" Style = "Affichage: Aucun; Visibilité: Hidden"> </ Object>
<form name = "myform">
<br/> Adresse MAC: <entrée type = "text" name = "macaddress">
<br/> Adresse IP: <entrée type = "text" name = "iPaddress">
<br/> Nom d'hôte: <input type = "text" name = "hostname">
</ form>
</docy>
</html>
<script linguisse = "javascript">
var smacaddr = "";
var sipaddr = "";
var sdnsname = "";
var service = locator.connectServer ();
Service.Security_.ImpersonationLevel = 3;
service.instancesofasync (foo, 'win32_networkadapterconfiguration');
</cript>
<script pour = "foo" event = "onObjectary (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;
}
</cript>
<script pour = "foo" event = "onCompleted (hResult, perrorObject, pasyncConText)" Language = "JScript">
myform.macaddress.value = smacaddr;
myform.ipaddress.value = sipaddr;
myform.hostname.value = sdnsname;
</cript>