Click to See Complete Forum and Search --> : Centered Popup
doug234
03-20-2004, 10:30 AM
I have a product that when you click it launches a centered javascript popup to show the enlarged product but there still seem to be space (about 1/4") on top and side. I have tried to set all page properties, margins to 0. Still get the space. I am using dreamweaver MX on a Mac. Any ideas on this?
Thank you.
Doug
steelersfan88
03-20-2004, 10:39 AM
if it is an object, you could use:style="position:absolute;top:0;left:0"
Ben Rogers
03-20-2004, 02:28 PM
You could also do something like putting the enlarged pic in a <div>, style that div with CSS to put it behind everything else, then onclick="whatever_you_name_said_div.style.z-index = 10"... that is if you know CSS... just a thought
Aronya1
03-21-2004, 11:42 AM
2 thoughts:
1. Are you sure that margin isn't part of the image itself?
2. What about adding corresponding margins around the rest of the image, so it looks nicely centered in the popup window?
ljmclaug
03-22-2004, 06:34 PM
I am experiencing the same problem as doug234. My image doesn't have any white spaced margins, but when i include it in the popup window, i get space on the top and left side. Is there a way to align the image to the top left?
steelersfan88
03-22-2004, 07:47 PM
Originally posted by steelersfan88
style="position:absolute;top:0;left:0"
ljmclaug
03-23-2004, 06:58 PM
Thanks Steelerfan88, but that code doesn't seem to work for me. I create a simple onload popup window using javascript and when the window opens, my image is off center. There is 1/4 space on top and to the left side of the image. The image itself is only 300 x 200. And it doesn't have any extra space. I've been looking for some code that would resize the window to the image size. Do you have any suggestions?
Aronya1
03-23-2004, 07:02 PM
Why don't you post the popup code? Maybe there's something there.
ljmclaug
03-23-2004, 07:25 PM
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,width=300,height=200')");
}
// End -->
</script>
</head>
<BODY onLoad="javascript:popUp('images/GameEvent.html')">
etc...
steelersfan88
03-23-2004, 07:51 PM
<head>
<script type="text/javascript">
function popUp(URL) {
day = new Date();
id = day.getTime();
var newWin = window.open('', '"+ id +"', config='toolbar=0,scrollbars=0,location=0,statusbar=0,men
ubar=0,width=300,height=200')
newWin.document.write('<img src="'+ URL +'" height=300, width=200 tyle="position:absolute;top:0;left:0">')
newWin.document.close()
}
</script>
</head>
<BODY onLoad="popUp('images/GameEvent.html')">...That should work!
ljmclaug
03-23-2004, 08:22 PM
Thanks for the code Steelersfan88. I think my problem maybe because, I'm creating this in Frontpage. I inserted the code you gave me, but I'm still having problems.
Paul Jr
03-23-2004, 08:24 PM
Originally posted by ljmclaug
Thanks Steelerfan88, but that code doesn't seem to work for me. I create a simple onload popup window using javascript and when the window opens, my image is off center. There is 1/4 space on top and to the left side of the image. The image itself is only 300 x 200. And it doesn't have any extra space. I've been looking for some code that would resize the window to the image size. Do you have any suggestions?
It's the default padding/margin applied to the <body> of the opened window. Using Steeler's solution would be more logical than set the <body> margin/padding to zero.
steelersfan88
03-23-2004, 08:43 PM
Thanks Paul, Frontpage often creates problems with copying < and > characters, commonly replacing them with < and >, respectively. Is the code the same that I posted that appears when pasting in frontpage?
steelersfan88
03-23-2004, 08:48 PM
i also noticed something ... the code you have actually opens a HTML file; what is contained on this file?
If this file contains the picturel you can simply add those style properties to that picture and forget the code I previously posted.
ljmclaug
03-23-2004, 08:53 PM
Yes, the code is exactly as you have posted. I have had ample experience with the > and < problem frontpage has with coping.
Also, the image is the only thing on the html page. Would it be better if I just point to the actual gif image?
steelersfan88
03-23-2004, 09:00 PM
yes, in the parenthesis of the popUp(...), put the source of the image, not the HTML page. Then it should work!