使用Java调整IE11大小的javascript
我有一个问题,试图在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);}
,但无法找出错误所在,因为控制台在kiosk模式下被禁用
目前正在使用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();
}
}
共 (0) 个答案