2015-10-15 123 views
-1

我試圖在iframe中自動運行Setup.exe。iframe中的自動執行.exe

一旦網站訪問者變成客戶面板註冊後彈出一個Java窗口運行setup.exe

該軟件將被執行將是我的客戶,誰是問服務檯的遠程訪問程序。

所以我試圖做一個與客戶端的形狀直接從頁面運行我的可執行文件,而無需下載。

見的,我怎麼做的一個例子:

main.js

var btnTitleChange = $.button("Let\'s change Frame title") 
    .on_click(changeTitle,"Wow, I changed!"); 

var frame = $.frame("Demo Application") 
    .layout($.layout("table",[[20,-1,20],[20,40,10,-1,20]])) 
    .add($.button("About").on_click(alert),"1,1") 
    .add(btnTitleChange,"1,3"); 

frame.show(); 

function changeTitle(title){frame.title(title);} 

function alert(){ 
    js.alert("Welcome to JavaScript executable!"); }; 

包括/ java.js

importPackage(Packages.java.lang) 
importPackage(Packages.java.awt) 
importPackage(Packages.java.awt.event) 
importPackage(Packages.javax.swing) 
importPackage(Packages.info.clearthought.layout); 

//============================= START OF CLASS ==============================// 
//CLASS: java_object               // 
//===========================================================================// 
/** 
    * A reference to the Java Object class 
    * @class 
    */ 
java_object = function(inst){ 
    /** 
    * Data container for this object 
    * @private 
    */ 
    this._d = {} 
    /** 
    * Contains the actual Java instance for this object 
    * To access it use the <b>instance()</b> method 
    * @private 
    */ 
    this._inst = new java.lang.Object();  
    this.instance = function(){return this._inst;} 
    this.equals = function(o){return (undefined===o._inst)?false:this._inst.equals(o.instance());} 
    this.getClass = function(){return this.instance().getClass();} 
    this.hashCode = function(){return this.instance().hashCode();} 
    this.toString = function(){return this.instance().toString();} 
}; 
//===========================================================================// 
//CLASS: java_object               // 
//============================== END OF CLASS ===============================// 

//============================= START OF CLASS ==============================// 
//CLASS: java_component              // 
//===========================================================================// 
/** 
    * A reference to the Java Component class 
    * @augments java_object 
    * @class 
    */ 
java_component = function(){ 
    this._inst = null; 
    //========================= START OF METHOD ===========================// 
    // METHOD: on_click             // 
    //=====================================================================// 
     /** 
     * Sets a function to be executed, when the mouse is clicked over this 
     * widget 
     * @param title the title to be shown in the frame 
     * @type mixed 
     */ 
    this.on_click=function(fn,arg1,arg2,arg3){ 
     var adapter = new java.awt.event.MouseAdapter() { mousePressed: function(e){fn(arg1,arg2,arg3);} };   
     this.instance().addMouseListener(adapter); 
     return this; 
    }; 
    //=====================================================================// 
    // METHOD: on_click             // 
    //========================== END OF METHOD ============================// 
}; 
java_component.prototype = new java_object(); 
java_component.constructor == java_object; 
//===========================================================================// 
//CLASS: java_component              // 
//============================== END OF CLASS ===============================// 

//============================= START OF CLASS ==============================// 
//CLASS: java_container               // 
//===========================================================================// 
/** 
    * A reference to the Java Container class 
    * @augments java_component 
    * @class 
    */ 
java_container = function(){ 
    this._inst = new java.awt.Container(); 
    //========================= START OF METHOD ===========================// 
    // METHOD: add              // 
    //=====================================================================// 
     /** 
     * Adds an object to the container. 
     * @type void 
     */ 
    this.add=function(object,constraints){ 
     if(undefined==constraints){ 
      (undefined===object.instance)?this.instance().add(object):this.instance().add(object.instance()); 
     }else{ 
      if(constraints.toUpperCase()=="NORTH"){ 
       (undefined===object.instance)?this.instance().add(object,BorderLayout.NORTH):this.instance().add(object.instance(),BorderLayout.NORTH); 
      }else if(constraints.toUpperCase()=="SOUTH"){ 
       (undefined===object.instance)?this.instance().add(object,BorderLayout.SOUTH):this.instance().add(object.instance(),BorderLayout.SOUTH); 
      }else if(constraints.toUpperCase()=="EAST"){ 
       (undefined===object.instance)?this.instance().add(object,BorderLayout.EAST):this.instance().add(object.instance(),BorderLayout.EAST); 
      }else if(constraints.toUpperCase()=="WEST"){ 
       (undefined===object.instance)?this.instance().add(object,BorderLayout.WEST):this.instance().add(object.instance(),BorderLayout.WEST); 
      }else{ 
       (undefined===object.instance)?this.instance().add(object,constraints):this.instance().add(object.instance(),constraints); 
      } 
     } 
     return this; 
    }; 
    //=====================================================================// 
    // METHOD: add              // 
    //========================== END OF METHOD ============================// 

    //========================= START OF METHOD ===========================// 
    // METHOD: layout              // 
    //=====================================================================// 
     /** 
     * Sets the layout for this container. 
     * @type void 
     */ 
    this.layout = function(layout){ 
     (undefined===layout.instance)?this.instance().setLayout(layout):this.instance().setLayout(layout.instance()); 
     return this; 
    }; 
    //=====================================================================// 
    // METHOD: layout              // 
    //========================== END OF METHOD ============================// 

    return this; 
} 
java_container.prototype = new java_component(); 
java_container.constructor == java_component; 
//===========================================================================// 
//CLASS: j_container               // 
//============================== END OF CLASS ===============================// 

//============================= START OF CLASS ==============================// 
//CLASS: java_frame               // 
//===========================================================================// 
/** 
    * A reference to the Java Window class 
    * @class 
    */ 
java_frame = function(title){ 
    this._inst = (undefined===title)?new javax.swing.JFrame(""):new javax.swing.JFrame(title); 
    this._inst.setSize(600,400);  
    this._inst.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 

    //========================= START OF METHOD ===========================// 
    // METHOD: show              // 
    //=====================================================================// 
    this.show=function(){this._inst.setVisible(true);}; 
    //=====================================================================// 
    // METHOD: show              // 
    //========================== END OF METHOD ============================// 

    //========================= START OF METHOD ===========================// 
    // METHOD: close              // 
    //=====================================================================// 
    this.close=function(){this._inst.setVisible(false);}; 
    //=====================================================================// 
    // METHOD: close              // 
    //========================== END OF METHOD ============================// 

    //========================= START OF METHOD ===========================// 
    // METHOD: on_close             // 
    //=====================================================================// 
     /** 
     * Sets or retrieves the title of this frame. 
     * @param title the title to be shown in the frame 
     * @type mixed 
     */ 
    this.on_close=function(fn,arg1,arg2,arg3){ 
     var adapter = new java.awt.event.WindowAdapter() { windowClosing: function(e){fn(arg1,arg2,arg3);} }; 
     this.instance().addWindowListener(adapter); 
     return this; 
    }; 
    //=====================================================================// 
    // METHOD: on_close             // 
    //========================== END OF METHOD ============================// 

    //========================= START OF METHOD ===========================// 
    // METHOD: title              // 
    //=====================================================================// 
     /** 
     * Sets or retrieves the title of this frame. 
     * @param title the title to be shown in the frame 
     * @type mixed 
     */ 
    this.title=function(/**String*/title){ 
     if(undefined===title)return this.instance().getTitle(); 
     else{this.instance().setTitle(title);} 
     return this; 
    }; 
    //=====================================================================// 
    // METHOD: title              // 
    //========================== END OF METHOD ============================// 
    return this; 
} 
java_frame.prototype = new java_container(); 
java_frame.constructor == java_container; 
//===========================================================================// 
//CLASS: j_frame                // 
//============================== END OF CLASS ===============================// 

//============================= START OF CLASS ==============================// 
//CLASS: j_layout               // 
//===========================================================================// 
/** 
* A reference to the Java Container class 
* @augments j_object 
* @class 
*/ 
java_layout = function(type,constraints){ 
    if(type==="border")this._inst = new java.awt.BorderLayout(); 
    if(type==="flow")this._inst = new java.awt.FlowLayout(); 
    if(type==="table"){ 
     this._inst = new TableLayout(constraints); 
    } 
    return this; 
} 
java_layout.prototype = new java_object(); 
//===========================================================================// 
//CLASS: j.layout               // 
//============================== END OF CLASS ===============================// 

//============================= START OF CLASS ==============================// 
//CLASS: j_button               // 
//===========================================================================// 
/** 
    * A reference to the Java JButton class 
    * <div style="position: relative; top: 10px; left: 10px; font-size: 11px; font-family: verdana; color:crimson;">&nbsp;Example&nbsp;</div> 
    * <div style="border: 1px dashed silver; margin: 10px; padding: 5px; background: cornsilk; font-family: monospace; font-size: 12px;"> 
    * var button = new j_button();<br> 
    *  button.text("Click me");<br> 
    *  button.on_click(js.alert,"I was clicked"); 
    * </div> 
    * @augments j_component 
    * @class  
    */ 
java_button = function(text){ 
    this._inst = (undefined===text)?new javax.swing.JButton(""):new javax.swing.JButton(text); 
    //========================= START OF METHOD ===========================// 
    // METHOD: text              // 
    //=====================================================================// 
    this.text=function(text){ 
     if(undefined===text){return this.instance().getText();} 
     this.instance().setText(text); 
    }; 
    //=====================================================================// 
    // METHOD: text              // 
    //========================== END OF METHOD ============================// 
    return this; 
} 
java_button.prototype = new java_component(); 
//===========================================================================// 
//CLASS: java_button               // 
//============================== END OF CLASS ===============================// 

//============================= START OF CLASS ==============================// 
//CLASS: namespace               // 
//===========================================================================// 
/** @namespace */ 
$ = { 
    _button:java_button, 
    _frame:java_frame, 
    _layout:java_layout, 
    _object:java_object, 
    button:function(name){ 
     return new this._button(name); 
    }, 
    frame:function(title){ 
     return new this._frame(title); 
    }, 
    layout:function(name,constraints){ 
     return new this._layout(name,constraints); 
    }, 
    object:function(){ 
     return new this._object(); 
    } 
}; 
//===========================================================================// 
//CLASS: namespace               // 
//============================== END OF CLASS ===============================// 

包括/ js.js

/** @namespace */ 
js = { 
    _loaded:[], // Reference to all the loaded script files 
    alert:function(msg){ 
     JOptionPane.showMessageDialog(null, "<html><font size=\"3\" color=\"red\">"+msg+"</font></html>", "Alert",JOptionPane.WARNING_MESSAGE); 
    }, 
    echo:function(msg){System.out.print(msg);}, 
    getcwd:function(){ 
     return System.getProperty("user.dir"); 
    }, 
    include:function(path){ 
     var id = path.split("\\").join("_").split(" ").join("___"); 
     if(undefined === this._loaded[id]){this._loaded[id]=id;} 
     load(path.split("\\").join("/")); 
    }, 
    include_once:function(path){ 
     var id = path.split("\\").join("_").split(" ").join("___"); 
     if(undefined === this._loaded[id]){ 
      this._loaded[id]=id; load(path.split("\\").join("/")); 
     } 
    }, 
    version:1.2 
} 
js.include("includes/java.js"); 

我想在圖片鏈接保持如圖所示:

如果任何人都可以準備給我的是iframe準備好,所以我可以學習更多關於它,並能夠實踐。

回答

0

您可以使用Java小程序來顯示您的Java應用程序。但現代瀏覽器(如Google Chrome,Microsoft Edge和Mozilla Firefox即將推出)終止了對插件NPAPI的支持,如Adobe Flash和Java Plugin。

所以,Java小程序已經過時並且非常不安全。

但如果你想這樣做,Oracle建議使用IE或Safari。

請參見官方頁面:https://java.com/en/download/faq/chrome.xml

+0

的答覆非常感謝。 Sera有另一種解決方案,我可以設法做到這一點? – Seth

+0

我不知道你的理由,但對我來說這是不切實際的。 –

+0

我在幫助臺網站 我們創建了一個遠程訪問系統。 客戶區要求您下載並安裝.msi文件 許多低和客戶不知道運行。 因此,我經常不得不在客戶的房子去執行 它最終給了我很多工作。 所以我試圖做到這一點 爲了方便,我不想做任何違法的事情。 因此,我可以看到我是否可以找到一個解決方案,我不會去客戶。他們中的許多人生活得很遠,很少有人瞭解它,無法找到要運行的文件。 但我理解你在倫理方面的問題。 但只是想同樣的方便。對我來說 – Seth