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?
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?
Share Improve this question asked Mar 18, 2013 at 7:26 Hadiyah MujhidHadiyah Mujhid 1871 gold badge2 silver badges11 bronze badges 4- 1 have you tried to provide height? – Jeff Robert Dagala Commented Mar 18, 2013 at 7:28
- yes, I've tried providing height. No change in result. – Hadiyah Mujhid Commented Mar 18, 2013 at 7:29
- 1 Strangely its works when u have a height attribute. See jsfiddle.net/YrRZu – Subir Kumar Sao Commented Mar 18, 2013 at 7:33
- 1 my apologies. Adding height does work! I was in full-screen mode last time I tried. – Hadiyah Mujhid Commented Mar 18, 2013 at 7:44
2 Answers
Reset to default 11it 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.
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