简体   繁体   English

从 Java 客户端服务器应用程序打开本地 Internet Explorer

[英]Open Local Internet explorer from Java Client Server Application

I have a client server application running on one machine(server machine).我有一个在一台机器(服务器机器)上运行的客户端服务器应用程序。 I open the application in my local machine by opening one browser(any) and typing the url of the application.我通过打开一个浏览器(任何)并输入应用程序的 url 在我的本地机器上打开应用程序。 Say the url is http://serverMachineName:8080/applicationContextPath/index.jsp .假设 url 是http://serverMachineName:8080/applicationContextPath/index.jsp

Then there is button in the screen.然后屏幕上有按钮。 When I click the button it should open the IE browoser in my local system.当我单击该按钮时,它应该会在我的本地系统中打开 IE 浏览器。 By Configuring Protocol Handler we might achieve this, but I didnt try this as we dont have that extent of access.通过配置协议处理程序我们可能会实现这一点,但我没有尝试这个,因为我们没有那个程度的访问权限。 Only way we can achieve this through is coding something.我们可以通过编码来实现这一点的唯一方法。 Using ProcessCommander or RunTime class I tried to do, but failed as that runs only on host machine that is, the server machine in this case, not my local one.我尝试使用 ProcessCommander 或 RunTime 类,但失败了,因为它只在主机上运行,​​即在这种情况下是服务器机器,而不是我的本地机器。 Java script also might do. Java 脚本也可以。

I don't know whether it will be useful to you.不知道对你有没有用。 I think you need something like below.I assume you can have button like below我想你需要像下面这样的东西。我假设你可以有像下面这样的按钮

<input type="button" Value="Test" onClick="RunBatch();"

your java script that calls batch script and uses ActiveXObject (which will throw security risks for first time access.You have to accept it).你的java脚本调用批处理脚本并使用ActiveXObject(第一次访问会引发安全风险。你必须接受它)。

function RunBatch(){
    var shell = new ActiveXObject("WScript.Shell");
    var path = '"C:/test.bat"';
    shell.run(path,1,false);
}

And in batch file test.bat you can have some thing like to open google.com in the internet explorer在批处理文件 test.bat 中,您可以在 Internet Explorer 中打开 google.com 之类的东西

start iexplore https://google.com

this will work only in IE browser as ActiveXObject is used这仅适用于 IE 浏览器,因为使用了 ActiveXObject

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM