1、页面弹框
<a style=" font-size: 11px; font-weight: normal; font-style: normal; text-decoration: none; color: rgb(51, 51, 51);"
class="2" οnclick="window.showModalDialog('<%=request.getContextPath()%>/inc/applet.jsp','','dialogHeight:200px;dialogWidth:400px;center:yes');">
<%=UtilTools.getLabelResource("LABEL_APPLET", currentLocale)%>
</a>
2、弹出页面
主要applet 可以用object标签
<script type="text/Jscript" src="<%=contextPath%>/js/jquery-1.9.1.min.js"></script>
<script language="javascript">
function viewResult(message)
{
$("#msg").append("<br>"+message);
}
</script>
</head>
<body>
<div id="msg">登录问题解决程序加载中,请等待...</div>
<applet archive="<%=contextPath%>/inc/ieBrowserEmulationApplet.jar"
code="com.huawei.IeBrowserEmulationApplet.class"
name="IeBrowserEmulationApplet" align="middle" width="0" height="0">
<param name="jnlp_href" value="
<%=contextPath%>/inc/ieBrowserEmulationApplet.jnlp">
<param name="permissions" value="all-permissions" />
</applet>
</body>
3、ieBrowserEmulationApplet.jar
-----------inc/ieBrowserEmulationApplet.jar
ieBrowserEmulationApplet.jar文件目录
--ieBrowserEmulationApplet
----src
----IE BrowserEmulation.reg
IE BrowserEmulation.reg
=============begin=================================
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation]
"AllSitesCompatibilityMode"=dword:00000001
===============end===============================
IeBrowserEmulationApplet.java
=============begin=================================
public class IeBrowserEmulationApplet extends Applet {
private static final long serialVersionUID = 1L;
public void init() {
exeJs("viewResult('登录问题解决程序执行中,请等待...')");
exec();
}
public void exec() {
if (RegeditUtil.query()) {
if (RegeditUtil.setIeEmulation()) {
System.out.println("登录问题已解决,请重启IE浏览器后生效!");
exeJs("viewResult('登录问题已解决,请重启IE浏览器后生效!')");
} else {
System.out.println("解决登录问题失败,请重试!");
exeJs("viewResult('解决登录问题失败,请重试!')");
}
} else {
System.out.println("当前系统无登录问题,无需执行此程序!");
exeJs("viewResult('当前系统无登录问题,无需执行此程序!')");
}
}
private String exeJs(String functionCmd) {
System.out.println(functionCmd);
String result = null;
JSObject jsObj = JSObject.getWindow(this);//
if (jsObj != null) {
result = (String) jsObj.eval(functionCmd);
}
return result;
}
}
=============end=================================
------------util/RegeditUtil.java
文件内容
=============begin=================================
public final class RegeditUtil {
//CMD查询注册表IE浏览器访问模式命令
private static String CMD_QUERY = "reg query \"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\BrowserEmulation\" /v AllSitesCompatibilityMode";
//执行设置注册表IE浏览器访问模式REG脚本
private static String CMD_IMPORT = "reg import \""+System.getProperty("user.dir")+"/IE BrowserEmulation.reg\"";
private static String VALUE = "0x0";
public static boolean query() {
BufferedReader bufferedReader = null;
boolean flag = true;
try {
Process process = Runtime.getRuntime().exec(CMD_QUERY);
bufferedReader = new BufferedReader(new InputStreamReader(process
.getInputStream()));
String line = null;
while ((line = bufferedReader.readLine()) != null) {
System.out.println(line);
if (!"".equals(line)) {
flag = false;
if (line.endsWith(VALUE)) {
return true;
}
}
}
return flag;
} catch (IOException e) {
System.err.println(e);
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception e) {
System.err.println(e);
}
}
}
return false;
}
4 、项目
--testPRO
------webroot
-----------js/jquery-1.9.1.min.js
-----------inc/ieBrowserEmulationApplet.jnlp
ieBrowserEmulationApplet.jnlp
=============begin=================================
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="ieBrowserEmulationApplet.jnlp">
<information>
<title>IeBrowserEmulationApplet</title>
<vendor>IeBrowserEmulationApplet</vendor>
<offline-allowed/>
</information>
<resources>
<!-- Application Resources -->
<j2se version="1.6+" href=
"http://java.sun.com/products/autodl/j2se"/>
<jar href="ieBrowserEmulationApplet.jar"
main="true" />
</resources>
<applet-desc name="IeBrowserEmulationApplet"
main-class="com.huawei.IeBrowserEmulationApplet"
<!-- Overwritten by the surrounding web page -->
width="1"
height="1">
</applet-desc>
<update check="background"/>
<security><all-permissions/></security>
</jnlp>
===============end===============================