简体   繁体   English

javascript:window.open

[英]javascript : window.open

I am working in vb.net 2005. I am in a position to start a new browser with process.start(). 我正在vb.net 2005中工作。我可以使用process.start()启动新的浏览器。 Now I have to open that browser in a specific size(say height:300 width:500) 现在,我必须以特定大小打开该浏览器(例如,高度:300宽度:500)

Process.Start("firefox.exe", "abc.html")

and I have written this following code on load of abc.html 并且我在加载abc.html时编写了以下代码

var myRef = window.open('abc.html','','left=20,top=20,width=300,height=500');

but it does not resize. 但不会调整大小。

If I add 1 button on this page and click on it (by writing same code on its click event), a new window with expected size opens. 如果我在此页面上添加1个按钮并单击它(通过在click事件上编写相同的代码),则会打开一个具有预期大小的新窗口。

Am I going wrong somewhere? 我在哪里出错了?

Thanx. 谢谢

Firefox doesn't let pages resize the window by default . Firefox 默认不允许页面调整窗口大小 Also note, if you already have Firefox running then browser preferences will dictate whether you get a new window or a tab. 另请注意,如果您已经在运行Firefox,则浏览器首选项将决定您是否获得新窗口或选项卡。 You can force a separate instance of Firefox by using the -no-remote command line flag, but then you won't be able to use the default profile (only one Firefox instance per profile). 您可以使用-no-remote命令行标志来强制使用Firefox的单独实例,但是您将无法使用默认配置文件(每个配置文件仅一个Firefox实例)。

My questions for you are: 我对您的问题是:

  • Why are you launching Firefox from another executable at all instead of just having users click on a link and have it open in their default browser? 为什么要从另一个可执行文件启动Firefox,而不仅仅是让用户单击链接并在默认浏览器中打开它?
  • If you do need to launch Firefox from an executable, why spend all this effort overriding the user's preferences and settings? 如果确实需要从可执行文件启动Firefox,为什么要花所有这些精力来覆盖用户的首选项和设置?
  • If you' re launching from an executable and are keen to annoy your users whatever the cost, why not just find and resize the Firefox window using the normal Windows APIs ? 如果您是从可执行文件重新启动,并想让您的用户烦恼而已,那么为什么不使用常规Windows API查找并调整Firefox窗口的大小呢?

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

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