window.open width ignored in Chrome

2019-04-27 00:53发布

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?

2条回答
淡お忘
2楼-- · 2019-04-27 01:32

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
查看更多
太酷不给撩
3楼-- · 2019-04-27 01:48

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.

查看更多
登录 后发表回答