Skip to content Skip to sidebar Skip to footer

Window.open Inconsistent Height For Browsers

I'm trying to create a simple pop-up window using this JS code: window.open(this.href,'popupwindow', 'width=400,height=545,innerHeight=500, left=200,top=5,scrollbars,toolbar=0,resi

Solution 1:

Resizing the window after opening may achieve better size accuracy:

var win = window.open("about:blank""popupwindow",  // about:blank for demo"width=400,height=500,left=200,top=5,scrollbars,toolbar=0,resizable");
// adjust size;
win.resizeBy( 400 - win.innerWidth, 500-win.innerHeight);

requests a window 400 x 500 pixels and then resizes the content area to make sure. Treatment or even recognition of innerHeight and width settings may differ between browsers.

However

Popup windows are subject to user preferences and popup blockers. For example I have IE set to open popups in a new tab (the code above does not open a new window), Firefox to always include the location bar, and regard any site that sets out to circumvent a popup blocker as malicious. You may wish to draw this to the attention of those setting the requirements.

Solution 2:

window.open(this.href,"popupwindow", "width=400,innerHeight=500,left=200,top=5,scrollbars,toolbar=0,resizable");

You can't predict the height of window. It's depends on user preferences. But you only need the innerHeight

Post a Comment for "Window.open Inconsistent Height For Browsers"