window.open width ignored in Chrome

末鹿安然 提交于 2019-12-22 04:49:16

问题


I want to create a popup of a fixed size, however the width attribute is ignored in Chrome. But Works fine in FF.

Here's my code:

window.open('','','width=300');

The resultant popup is larger than the given width.

Any suggestions?


回答1:


I have tried to put this one on Chrome version 25.0.1364.172

window.open('','','width=200,height=100');

and it correspond the exact height and width of the window.

to check, please use

window.innerHeight; //to display height
window.innerWidth; //to display width



回答2:


it would seem to be some bizarre quirk in Chrome, that you have to specify both a width and a height to get it to observe the dimensions set. If you only specify a height, or a width, then that single dimension is ignored. Hence why in the other answer it worked fine for Jeff.



来源:https://stackoverflow.com/questions/15471657/window-open-width-ignored-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!