I am creating popup windows using window.open and setting the height and width of the created screen.
The navigation bar always appears (since this is a browser setting beyond my control). The problem is in IE/Firefox the navigation bar is excluded from the height I define which is good, but in Chrome, it is not, so my popup ends up being undersized with a right scrollbar.
What’s the preferred mechanism for dealing with this.
Using a function to set the popup-height which checks the browser type and adds adjustments depending on the result?
function popupCreator(url, popupname, height, width){
if(browsertype=="chrome"){ //obviously not this exact code!
height = height + 20;
}
var params = 'width=' + width + ',height=' + height;
newwin = window.open(url, popupname, params);
}
Or is there a better way of achieving this?
The full function I am currently using:
"popup": function (url, popupname, height, width) {
if (null == width) {
var width = screen.width / 2;
}
if (null == height) {
var height = screen.height / 2;
}
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var params = 'width=' + width + ',height=' + height;
params += ',top=' + top + ',left=' + left;
params += ',directories=no';
params += ',location=no';
params += ',menubar=no';
params += ',resizable=no';
params += ',scrollbars=no';
params += ',status=no';
params += ',toolbar=no';
params += ',dialog=yes';
params += ',titlebar=no';
newwin = window.open(url, popupname, params);
if (window.focus) { newwin.focus() }
return false;
},
The visibility of navigation bar is controllable. For instance:
Location is the only thing that cannot be hidden, because of security reasons.