【发布时间】:2021-12-21 20:33:09
【问题描述】:
我在尝试在 kiosk 模式下调整 IE11 的大小时遇到问题,但在 kiosk 模式下启动会强制它进入全屏模式,但如果我关闭 kiosk 模式,工具栏和导航栏等都将可见,这不是我想要的想阻止用户编辑网址,所以我能做到吗?我尝试使用 JS,但它没有工作。不使用JS可以吗?
我试过Process p = new ProcessBuilder("cmd.exe", "/c", "start iexplore -k javascript:resizeTo(400,300)\"" + newUrl +"\"").inheritIO().start();,但它提示保存文件对话框,而不是调整大小。
也尝试过javascript:moveTo(0,0);resizeTo(1024,768);},无法找出问题所在,因为控制台在信息亭模式下被禁用。
目前使用java-8。
private static String newUrl = replaceUserID(url);
public static void main(String[] args) {
try{
Process p = new ProcessBuilder("cmd.exe", "/c", "start iexplore -k \"" + newUrl +"\"").inheritIO().start();
resizeBrowser();
try{
p.waitFor();
}
catch( InterruptedException ie ){
System.out.println("InterruptedException " + ie.getMessage());
}
InputStream err = p.getErrorStream();
int ctr = 0;
if ( (ctr = err.available()) > 0 ){
byte[] buf = new byte[ctr];
System.out.println("Process failed with error:\n" + new String(buf, 0, ctr));
}
}
catch(IOException ioe)
{
System.out.println("InterruptedException " + ioe.getMessage());
}
}
public static void resizeBrowser() {
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine javaScript = scriptEngineManager.getEngineByName("nashorn");
try {
javaScript.eval("function resizeIE(){"
+ "newWindow = window.open(\"" + newUrl + "\", IEWindow, resizable);"
+ "newWindow.resizeTo(500,400);}");
}catch (ScriptException e) {
e.printStackTrace();
}
}
【问题讨论】:
标签: javascript java internet-explorer-11