View Full Version : Can I have a window measured by font size?
vw98034
02-25-2004, 07:37 PM
To make sure a popup window has a consistant appearance across various screen resolutions, the window size shall vary based on the resolution. Can I have a popup window measured by the font size, something like the "em" in CSS?
Thanks for your inputs.
lavalamp
02-25-2004, 11:03 PM
You could quite easily set the content width depending on the font size by including all of your content inside a div tag with a width set using em's, however I'm not sure about the window size.
IMO it would be easier to just have a set window size but make sure that your inline content can collapse in width gracefully and so create a more fluid layout.
vw98034
02-26-2004, 12:10 AM
Hi,
Thanks for your response.
I get your point. But the popup window size seems having a better fit with the content. I find the follow javascript code which is close to my need. Unfortunately, it has an error. I can't find out any problems on the line.
function showpopup() {
var putItThere = null;
var chasm = screen.availWidth;
var mount = screen.availHeight;
var wd = chasm*.9; // percentage of screen width occupied by pop-up
var ht = mount*.8; // percentage of screen height occupied by pop-up
// The following line has an error. What it is?
putItThere = window.open('...','Tour','width='+wd+',height='+ht+', left='+((chasm-wd-10)*.5)+',top='+((mount-ht-25)*.5)+',scrollbars,status,titlebar');
return true;
}
lavalamp
02-26-2004, 01:49 AM
You could simplify that code so much you know, but no matter, I think I see your error. I have a screen resolution of 1024x768, I'll work out the numbers for that:
chasm - wd = 1024 - 921.6 = 102.4
102.4 * 0.5 = 51.2
mount - ht - 25 = 768 - 614.4 - 25 = 128.6
128.6 * 0.5 = 64.3
So you are making a window which is 51.2px to the left and 64.3px down. I don't think you can do 0.2 of a pixel.
It seems as though you are trying to centre the pop-up window both horizontally and vertically, to do that you could just do this:
var chasm = screen.availWidth;
var mount = screen.availHeight;
var putItThere = window.open('... ','Tour','width='+Math.round(chasm*0.9)+',height='+Math.round(mount*0.9)+',left='+Math.round(chasm*0 .1-5)+',top='+Math.round(mount*0.1-12.5)+',scrollbars,status,titlebar');
whammy
02-26-2004, 02:23 AM
This is double-posted...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.