How JavaScript invokes the client Java program _javascript tips

Source: Internet
Author: User

The example in this article describes the way JavaScript invokes the client Java program. Share to everyone for your reference. Specifically as follows:

Generally speaking, JavaScript does not have permission to invoke the client to execute the program. But sometimes there are special needs that have to be invoked. For example, sometimes it involves the operation of the client file, and of course we can do it with the FileSystemObject object. For example, in our previous projects, the need is to click on the page a link does not pop ie file Download dialog box (there are three options: Open, Save, cancel the one), directly download the file to the specified directory. At this point you have to bypass the browser's dialog box, write a client's Java program to achieve the download. This code is tested in IE8, to set your site as a trusted site, and then to enable the "Initialize not marked as Safe ActiveX Control" entry in the Trusted Site security options in the browser.

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 \ n program blocks this until the client client program returns to
    Objshell=null; 
    Window.status= "Operation ended. ";
  } catch (e) {
    alert ("Operation failed!) The reason may be that the browser security option is not set incorrectly or the client handler cannot be found.

I hope this article will help you with your JavaScript programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.