问题描述
我正在使用以下代码打开一个最大化的弹出窗口,我不想全屏打开它(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);
这篇关于javascript (window.open) 在所有浏览器中打开最大化,但在 chrome 中不打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!