Height.open is not the same in Google Chrome as other browsers

I use javascript window.open to open a browser window on a user click on a specified width and height (760x581), and this works correctly in Internet Explorer, Safari and Firefox, but Google Chrome gives me problems. In other browsers, the height is correctly used as the height of the content, but in Google Chrome it makes the actual browser window 581 pixels higher than the content. Is there any way to fix this?

<a href="http://domain.com/example.php" onclick="window.open('http://domain.com/example.php', '', 'width=760, height=581, top=15, left=15, toolbar=0, menubar=0, scrollbars=1, resizable=1, copyhistory=0, location=0, directories=0, status=1, titlebar=1, personalbar=0');return false">click here</a> 
+6
javascript google-chrome popup
source share
3 answers

So, I messed up things more and found that some browsers supported the innerHeight property for window.open , and worked in all browsers as expected in all browsers with the desired content height of 775px with 50px added only in Chrome:

 window.open($(this).attr('href'), 'videoplayer', 'width=1242, height=775, innerHeight=825, location=no, menubar=no, status=no, titlebar=no, scrollbars=no' ); 

I tested this on Chrome 6.0.472.63, Firefox 3.6, 3 and 2, IE 8 and 7, and Opera 10.62. When I used only height , Chrome would be around 50px too short and have scrollbars, but all of the above browsers were fine. With the added added innerHeight property set to 50 pixels larger than I want, it worked in both Chrome and all other browsers.

Update: It looks like this is creating a problem in Safari with added 50px height. See how to get around this.

+4
source share

The problem still persists (Chrome17 +) if you call window.open with height = 600, the innerheight result window is 564px, which is 36px less (for the title bar on Windows). The height of the header depends on the platform, so this is very annoying.

My solution just added a difference in height.

+1
source share

Well, due to the fact that I was able to find after an Google search for more than an hour, this is how Google Chrome does it, and we just need to use a workaround. What I'm doing right now, unless something better is found, just puts the following JS on the page that opens:

 if (navigator.appVersion.indexOf('Chrome')>0) { window.resizeBy(0, 581 - window.innerHeight); } 
0
source share

All Articles