This article mainly introduces how to call the Java program of the client using JavaScript. The example analyzes the related skills of javascript to call the java program and has some reference value, for more information about how to use JavaScript to call the client Java program, see the example in this article. Share it with you for your reference. The details are as follows:
Generally, JavaScript has no permission to call the executable program on the client. But sometimes some special needs have to be called. For example, you can use the FileSystemObject object to perform operations on client files. For example, in the previous project, the requirement is to click a link on the page and the File Download Dialog Box for IE is not displayed (there are three options: open, save, and cancel ), directly download the file to the specified directory. In this case, you have to bypass this dialog box in the browser and write a java program on the client to download it. This code passes the test in IE8 and sets your site as a trusted site, set the "initialize ActiveX control not marked as secure" item in the trusted site security option of the browser to Enable.
Function callJava () {try {var strPath = "C: \ AJava. jar "; \ Client java program path var objShell = new ActiveXObject (" WScript. shell "); window. status = "operation in progress. Please wait ...... "; objShell. run (strPath, 8, true); \ the program will block this until the client program returns objShell = null; window. status = "operation ended. ";} Catch (e) {alert (" operation failed! The reason may be that the browser security option is set incorrectly or the client handler cannot be found .");}}
I hope this article will help you design javascript programs.