h5中不能用js来获取mac的。是可以获取ip的。代码
<script>
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wsh = new ActiveXObject("WScript.Shell");
wsh.Run("command.com /c ipconfig /all > C:\ip.txt");
var f = fso.OpenTextFile("C:\ip.txt");
var s = f.ReadAll();
f.Close();
alert(s.match(/IP Address(. )+: ((d{1,3}.){3}(d{1,3}))/i)[2])
</script>
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wsh = new ActiveXObject("WScript.Shell");
wsh.Run("command.com /c ipconfig /all > C:\ip.txt");
var f = fso.OpenTextFile("C:\ip.txt");
var s = f.ReadAll();
f.Close();
alert(s.match(/IP Address(. )+: ((d{1,3}.){3}(d{1,3}))/i)[2])
</script>
new ActiveXObject 是IE浏览器专属的
IE浏览器还会提示授权才能使用