JS獲取幾種URL地址的方法小結(jié)
以下為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地址及主機(jī)名的方法:
<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" style="display:none;visibility:hidden"></object>
<form name="myForm">
<br/>MAC地址:<input type="text" name="macAddress">
<br/>IP地址:<input type="text" name="ipAddress">
<br/>主機(jī)名:<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>
- 讓網(wǎng)頁上的超鏈接失效,不能點(diǎn)擊的js代碼
- Ext javascript建立超鏈接,進(jìn)行事件處理的實(shí)現(xiàn)方法
- JavaScript asp.net 獲取當(dāng)前超鏈接中的文本
- js 取消超鏈接的方法小結(jié)
- js修改地址欄URL參數(shù)解決url參數(shù)問題
- JavaScript將相對地址轉(zhuǎn)換為絕對地址示例代碼
- 使用JavaScript修改瀏覽器URL地址欄的實(shí)現(xiàn)代碼
- javascript/jquery獲取地址欄url參數(shù)的方法
- js實(shí)現(xiàn)a標(biāo)簽超鏈接提交form表單的方法
- 巧方法 JavaScript獲取超鏈接的絕對URL地址
相關(guān)文章
Three.Js實(shí)現(xiàn)看房自由小項(xiàng)目
目前隨著元宇宙概念的爆火,THREE技術(shù)已經(jīng)深入到了物聯(lián)網(wǎng)、VR、游戲、數(shù)據(jù)可視化等多個(gè)平臺(tái),今天我們主要基于THREE實(shí)現(xiàn)一個(gè)三維的VR看房小項(xiàng)目,感興趣的朋友跟隨小編一起看看吧2022-10-10javascript筆記 String類replace函數(shù)的一些事
加固javascript基礎(chǔ)知識目的是為以后研究jQuery源碼做好鋪墊。2011-09-09基于javascript實(shí)現(xiàn)tab選項(xiàng)卡切換特效調(diào)試筆記
這篇文章主要介紹了基于javascript實(shí)現(xiàn)tab選項(xiàng)卡切換特效調(diào)試筆記,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03JavaScript設(shè)置、獲取、清除單值和多值cookie的方法
cookie 是存儲(chǔ)于訪問者的計(jì)算機(jī)中的變量。每當(dāng)同一臺(tái)計(jì)算機(jī)通過瀏覽器請求某個(gè)頁面時(shí),就會(huì)發(fā)送這個(gè) cookie。你可以使用 JavaScript 來創(chuàng)建和取回 cookie 的值,本文通過一段代碼給大家介紹js設(shè)置、獲取、清除單值和多值cookie的方法,需要的朋友一起學(xué)習(xí)吧2015-11-11使用getBoundingClientRect方法實(shí)現(xiàn)簡潔的sticky組件的方法
本文介紹這種組件的實(shí)現(xiàn)思路,并提供一個(gè)同時(shí)支持將sticky元素固定在頂部或底部的具體實(shí)現(xiàn),由于這種組件在網(wǎng)站中非常常見,所以有必要掌握它的實(shí)現(xiàn)方式,以便在有需要的時(shí)候基于它的思路寫出功能更多的組件出來2016-03-03僅Firefox中鏈接A無法實(shí)現(xiàn)模擬點(diǎn)擊以觸發(fā)其默認(rèn)行為
偶然發(fā)現(xiàn)之前寫的事件模塊在Firefox5中無法觸發(fā)A的默認(rèn)行為了。IE/Opera/Firefox5中A具有click方法,因此模擬點(diǎn)擊直接調(diào)用click方法即可。2011-07-07