简体   繁体   English

如何在Java中调整Internet Explorer浏览器的大小

[英]How to resize Internet Explorer browser in Java

I am trying to open an Internet Explorer window from Java code as below: 我正在尝试从Java代码打开Internet Explorer窗口,如下所示:

Runtime.getRuntime().exec(folder + ":\\Program Files\\Internet Explorer\\IEXPLORE.EXE  http://google.com/");

That works fine but my requirement is to open the window at a small size, for which I followed the link How do you resize an IE browser window to 1024 x 768 . 效果很好,但我的要求是以小尺寸打开窗口,为此我点击了链接如何将IE浏览器窗口的尺寸调整为1024 x 768 But I don't know how I can use the JavaScript solution from Java code. 但是我不知道如何使用Java代码中的JavaScript解决方案。

I tried passing it on the command line: 我尝试在命令行中传递它:

Runtime.getRuntime().exec(folder + ":\\Program Files\\Internet Explorer\\IEXPLORE.EXE javascript:resizeTo(1024,768); http://google.com/"); 

But it is not working. 但这是行不通的。 Please suggest if you have any idea. 请提出您的想法。

Thanks in advance. 提前致谢。

if you try \\\\Program Files\\\\Internet Explorer\\\\iexplore javascript:resizeTo(1024,768); http://google.com/ 如果您尝试\\\\Program Files\\\\Internet Explorer\\\\iexplore javascript:resizeTo(1024,768); http://google.com/ \\\\Program Files\\\\Internet Explorer\\\\iexplore javascript:resizeTo(1024,768); http://google.com/ on a command line, you will find it does not do what you are expecting. 在命令行\\\\Program Files\\\\Internet Explorer\\\\iexplore javascript:resizeTo(1024,768); http://google.com/上,您会发现它没有达到您的期望。

iexplore does not seem to respect the javascript protocol properly in this scenario. 在这种情况下,iexplore似乎并未正确遵守javascript协议。

When i tried, it seems to open the save file dialog rather than running the code. 当我尝试时,似乎打开了保存文件对话框,而不是运行代码。 I suggest this is the problem you need to workaround. 我建议这是您需要解决的问题。

I have not investigated further, but you might try a custom protocol handler or some other way of having iexplore run the js, whether from the CLI or otherwise. 我没有进一步研究,但是您可以尝试使用自定义协议处理程序或其他使iexplore运行js的方式,无论是从CLI还是其他方式。

 javascript:resizeTo(1024,768); vbscript:resizeto(1024,768) 

Will work in IE7, But consider using something like 可以在IE7中使用,但请考虑使用类似

 javascript:moveTo(0,0);resizeTo(1024,768); 

because IE7 doesn't allow the window to "resize" beyond the screen borders. 因为IE7不允许窗口“调整大小”超出屏幕边界。 If you work on a 1024,768 desktop, this is what happens... 如果您在1024,768桌面上工作,则会发生这种情况...

Firefox: 1024x768 Window, going behind the taskbar. Firefox:1024x768窗口,位于任务栏后面。 If you drop the moveTo part, the top left corner of the window won't change position.(You still get a 1024x768 window) IE7: As close as possible to the requested size without obscuring the taskbar or allowing any part of the window to lie beyond the screen borders. 如果删除moveTo部分,则窗口的左上角将不会改变位置。(您仍将获得1024x768窗口)IE7:尽可能接近请求的大小,而不会遮挡任务栏或允许窗口的任何部分超出屏幕边界。 safari: As close as possible to the requested size without obscuring the taskbar or allowing any part of the window to lie beyond the screen borders, but you can ommit the moveTo part. safari:尽可能接近要求的大小,而不会遮挡任务栏或允许窗口的任何部分位于屏幕边界之外,但是您可以省略moveTo部分。 Safari will move the top left corner of the window for you. Safari会为您移动窗口的左上角。 Opera: Nothing happens. 歌剧:什么都没发生。 Chrome: Nothing happens. Chrome:什么都没发生。

This quote is from: Tolle you can find his post here: How do you resize an IE browser window to 1024 x 768 这句话的来源是:Tolle,您可以在这里找到他的文章: 如何将IE浏览器窗口的大小调整为1024 x 768

Hopefully this is help full to you! 希望这对您有很大帮助!

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

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