javascript (window.open) opens maximized in all browsers but not in chrome(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);
这篇关于javascript (window.open) 在所有浏览器中打开最大化,但在 chrome 中不打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:javascript (window.open) 在所有浏览器中打开最大化,但在 chrome 中不打开
基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
