提示:Active并不安全,存在一定的风险,且仅适用于ie。
第一步,开启ActiveX,设置完毕后,记得重启浏览器(关了重开)
也可以使用批处理开启,将以下内容复制到txt文件中,并将后缀改成bat,点击运行就行了。
@echo off
title IE ActiveX Plug-in enabler script
echo IE ActiveX Plug-in is enabled...
ping 127.0.0.1 -n 2 >nul 2>nul
set bl=0
:setreg
if "%bl%"=="1" goto ex
set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
cls
:start “ActiveX Plug-in”
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
set /a bl=%bl%+1
goto setreg
:ex
cls
echo success
echo This procedure will be closed automatically later...
ping 127.0.0.1 -n 8 >nul 2>nul
exit
第二步,使用javaScript获取本机macip地址
<HTML>
<HEAD>
<TITLE>mac</TITLE>
<script type="text/javascript">
function load() {
console.info('1111');
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled =True");
var e = new Enumerator(properties); {
var p = e.item();
console.info(p);
var mac = p.MACAddress;
document.getElementById("mac").value = mac;
}
}
</script>
</HEAD>
<BODY onload="load()">
<input type="text" id="mac" name="mac" />
</BODY>
</HTML>
第三步(可选),关闭ie的安全提示(毕竟Active不安全)
- 按win+R调出【运行】
- 在【运行】中输入gpedit.msc
- 右击,出现【编辑】,点击【编辑】,点击【启用】,点击【确定】
- 就能关闭ie的安全提醒