Home > Web Front-end > JS Tutorial > JavaScript method to run local programs in web pages_javascript skills

JavaScript method to run local programs in web pages_javascript skills

WBOY
Release: 2016-05-16 15:16:25
Original
1325 people have browsed it

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>

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template