gpt4 book ai didi

java - Java 小程序部署工具包 : how to avoid the redirect when no JVM is installed

转载 作者:行者123 更新时间:2023-11-29 18:24:32 26 4
gpt4 key购买 nike

我创建了一个小程序;它是使用 Deployment Toolkit 部署的如下(网址是假的):

<script type="text/javascript" 
src="https://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
code:'br.com.brandizzi.adam.applet.MyApplet.class',
archive:'http://adam.brandizzi.com.br/html/applet.jar',
width : 50,
height : 1
};
var parameters = {
fontSize : 1,
};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>

效果很好。然而,幸运的是,我通过一台没有 JVM 的机器访问了我的站点,它总是被重定向到 http://www.java.com。 - 作为 the documentation states :

If the client does not have the required minimum version of the JRE software, the Deployment Toolkit script redirects the browser to http://www.java.com to allow users to download the latest JRE software. On some platforms, users might be redirected before they can view the web page containing the applet.

有没有办法避免这种重定向?页面在没有 JVM 的情况下也能很好地工作,小程序只是一点点改进。无论如何,我们的用户可能会对这种重定向感到非常困惑,他们甚至没有安装 JVM 的权限。

最佳答案

如果你看一下 deployJava.js 脚本,runApplet 函数是这样的:

     /**
* Ensures that an appropriate JRE is installed and then runs an applet.
* minimumVersion is of the form #[.#[.#[_#]]], and is the minimum
* JRE version necessary to run this applet. minimumVersion is optional,
* defaulting to the value "1.1" (which matches any JRE).
* If an equal or greater JRE is detected, runApplet() will call
* writeAppletTag(attributes, parameters) to output the applet tag,
* otherwise it will call installJRE(minimumVersion + '+').

所以如果你这样打电话

deployJava.runApplet(attributes, parameters, null);

或者像这样

deployJava.runApplet(attributes, parameters, 'undefined');

或者像这样

deployJava.runApplet(attributes, parameters, '1.1');

它只会检查是否 完全 安装了 Java,然后才重定向到 java.com 进行安装。既然你有一个小程序,你就需要 Java :)

或者,您可以直接调用deployJava.writeAppletTag(attributes, parameters):

    /**
* Outputs an applet tag with the specified attributes and parameters, where
* both attributes and parameters are associative arrays. Each key/value
* pair in attributes becomes an attribute of the applet tag itself, while
* key/value pairs in parameters become <PARAM> tags. No version checking
* or other special behaviors are performed; the tag is simply written to
* the page using document.writeln().
*
* As document.writeln() is generally only safe to use while the page is
* being rendered, you should never call this function after the page
* has been completed.
*/

关于java - Java 小程序部署工具包 : how to avoid the redirect when no JVM is installed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14875135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com