Search code examples
javascripthtmlhref

Using JavaScript to open a window to a specific size


I'm wanting to open a window to a specific size using the window.open method when my button div is clicked. I referenced some other online sources, and got it this far.

<div class="button" onclick="window.open('http://google.com', '_blank', 'width=600', 'height=600');return false;"></div>

I'm not sure what I'm doing wrong, the width works in firefox, however the height does not. None of it works in Chrome.


Solution

  • All the window options go in one string:

    <div class="button" onclick="window.open('http://google.com', '_blank', 'width=600, height=600');return false;"></div>