The example in this article describes how to implement javascript to run local programs in web pages. Share it with everyone for your reference, the details are as follows:
<input onclick="exec('notepad.exe')" value="执行noteppad.exe" type="button"> <input onclick="exec('cmd.exe')" value="执行cmd.exe" type="button"> <script language="javascript"> function exec(command) { window.oldOnError = window.onerror; window._command = command; window.onerror = function (err) { if (err.indexOf('utomation') != -1) { alert('命令' + window._command + ' 已经被用户禁止!'); return true; } Else return false; }; //-----------// var wsh = new ActiveXObject('WScript.Shell'); if (wsh) wsh.Run(command); wsh = null; window.onerror = window.oldOnError; } </script>
Readers who are interested in more JavaScript-related content can check out the special topics on this site: "Summary of JavaScript errors and debugging skills", "Summary of JavaScript extension skills" and "Summary of JavaScript data structure and algorithm skills》
I hope this article will be helpful to everyone in JavaScript programming.