javascript implements a method for running local programs in a Web page
- 2020-12-10 00:35:52
- OfStack
This article illustrates the javascript implementation of running native programs on a web page. To share for your reference, the details are as follows:
<input onclick="exec('notepad.exe')" value=" perform noteppad.exe" type="button">
<input onclick="exec('cmd.exe')" value=" perform 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(' The command ' + window._command + ' Has been banned by the user! ');
return true;
}
Else
return false;
};
//-----------//
var wsh = new ActiveXObject('WScript.Shell');
if (wsh) wsh.Run(command);
wsh = null;
window.onerror = window.oldOnError;
}
</script>
For more information about JavaScript, please refer to: Summary of JavaScript Error and Debugging Skills, Summary of JavaScript Extension Skills and Summary of JavaScript Data Structure and Algorithm Skills.
I hope this article has been helpful in JavaScript programming.