我實際測試了一下:使用 IE 內核的瀏覽器都能支援,而 Firefox 似乎行不通。
<html>
<head>
<script type="text/javascript">
function callExe()
{
// new ActiveXObject("Wscript.Shell").run("notepad.exe D:\\a.png.txt");
//
new ActiveXObject("Wscript.Shell").run("D:\\工具\\Pb6安裝\\Pb6安裝\\SETUP.EXE");
}
</script>
</head>
<body>
<input id="Button2" type="button" value="調用" onclick="callExe();" />
</body>
</html>
關鍵在於 ActiveXObject("Wscript.Shell").run(...),它能讓瀏覽器去啟動本機的執行檔。不過這套做法高度依賴 IE 的 ActiveX 機制,且會觸發安全性警告,僅適合受控的內部環境使用,現代瀏覽器基於安全考量已全面禁用。