javascript(window.open)在所有浏览器中最大化打开,但在chrome中不最大化
我正在使用以下代码打开最大化的弹出窗口,我不想全屏打开它(F11),我只需要最大化它,就像在最小化和关闭之间按下按钮一样.
I am using the following code to open a maximized pop up window, i don't want to open it full screen (F11), I need it just maximized, exactly like pressing the button between minimize and close.
<a onclick="javascript:w= window.open('https://www.facebook.com/mywifemylove','_blank','channelmode =1,scrollbars=1,status=0,titlebar=0,toolbar=0,resizable=1');" href="javascript:void(0);" target="_blank">Maximized on Chrome</a>
它对所有浏览器都能正常运行,但不适用于Chrome浏览器,这是 jsfiddle 进行测试
It's working fine for all browsers but not Chrome, Here is a jsfiddle for testing
除IE之外,浏览器均不支持使用JS全屏显示.这是故意的:
With the exception of IE, browsers do not support going fullscreen with JS. This is intentional:
https://developer.mozilla.org/zh-CN/docs/Web/API/window.open#FAQ
"所有浏览器制造商都在尝试开设新的次要浏览器 用户注意到并为避免混淆而引起用户注意的窗口, 避免使用户迷惑."
"All browser manufacturers try to make the opening of new secondary windows noticed by users and noticeable by users to avoid confusion, to avoid disorienting users."
您可以将窗口的大小手动设置为屏幕大小,但是可能需要处理诸如边框宽度之类的事情.
You can manually set the size of the window to the screen size but you may have to deal with things like frame border thickness.
相关的SO问题: 如何使用Javascript打开最大化的窗口?
在最新版本的IE,FF或Chrome上,最大尺寸"窗口的工作代码:
Working code for max size window on latest versions of IE, FF or Chrome:
window.open('http://www.stackoverflow.com','_blank','height='+screen.height+', width='+screen.width);