PDA

View Full Version : Centering in a pop up


Bobba Buoy
12-27-2003, 08:40 AM
I use the following function to show info in pop-ups:

<script LANGUAGE="JavaScript">
<!--
function pop(url)
{
window.open(url,'profile','width=450,height=450,resizable');
}
//-->
</script>



Is there a way to center the contents in the pop-up? I am usually showing a picture in a table. If not, can I use variables to size the pop-up to fit the picture (this would be the best-case scenario).

Thanks!

illogique
12-27-2003, 08:53 AM
function pop(url)
{
x = math.round((window.width-450)/2);
y = math.round((window.height-450)/2);
window.open(url,'profile','width=450,height=450,resizable,left='+x+',top='+y);
}

Bobba Buoy
12-27-2003, 08:58 AM
Thanks!

Bobba Buoy
12-27-2003, 09:08 AM
Oops. That didn't work. I don't want to center the pop-up on the screen, I want to center the pop-up contents (the table) in the window.

coothead
12-27-2003, 09:58 AM
Hi there Bobba Buoy,

If you want the pop-up to fit tightly
around the image and the containing table
set the pop up dimensions to that of the
table and add this to the body tag of the
image_and_table.html...

<body style="margin:0;">

If you want a margin around the table...
say 20px then increase the dimensions of the pop-up by 40px and change the body tag to

<body style="margin:20px 20px;">

c:cool::cool:thead

illogique
12-28-2003, 07:24 PM
a popup is just a way to display a web page so if you want the web page to be center than you got to edit that page to make it center, nothing to do with the popup...