...

View Full Version : JS Popup Showing Blank Space



kraftomatic
03-07-2005, 02:40 PM
Hey Guys,

Simple question here. I've got the following JS function:

// new popup function
function popUp(URL) {
window.open( URL, "_blank", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600");
}


And I'm calling it like this:

<a href="javascript::popUp('images/gallery/imageName.jpg')"><img src="images/imageName_thumb.jpg" /></a>

So a nice 800x600 window pops up with the image. However, there is approximately a 10 pixel gap on the top and left side of the "page". I want the image to completely take up the window.

It's almost like a margin or padding setting, but I haven't set any of that. It's not really opening a "page" persay, but the image itself.

How can I get rid of this?

Thanks.

liorean
03-07-2005, 02:57 PM
Open a page that eliminates the margin and padding of the html and body elements, and that embeds the image.

kraftomatic
03-07-2005, 03:09 PM
Open a page that eliminates the margin and padding of the html and body elements, and that embeds the image.

But then I need an HTML page for every image.

liorean
03-07-2005, 03:40 PM
No. You need a single server side script that just inserts the image address into a template page.

kraftomatic
03-07-2005, 05:07 PM
Any idea why the blank space would be occuring on just opening the image?

_Aerospace_Eng_
03-07-2005, 05:51 PM
because when you link to an image you have no formatting however you can use some javascripting to get rid of the border, try this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<script type="text/javascript">
function writeimg(what,wid,hgt,which){
sw=(screen.width-wid)/2;
sh=(screen.height-hgt)/2;
newwin=window.open('','','width='+wid+',height='+hgt+',top='+sh+',left='+sw+',menubars=0,scrollbars= 0,status=0,location=0,directories=0');
newwin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"');
newwin.document.write('"http://www.w3.org/TR/html4/loose.dtd">');
newwin.document.write('<head>');
newwin.document.write('<title>'+what+'</title>');
newwin.document.write('<style type="text/css">');
newwin.document.write('body {background:#000000;color:#FFFFFF;margin:0px;padding:0px;}');
newwin.document.write('img {border:0px;}');
newwin.document.write('</style>');
newwin.document.write('</head>');
newwin.document.write('<body>');
newwin.document.write('<img src="'+which+'" width="'+wid+'" border="0" height="'+hgt+'" alt="'+what+'">');
newwin.document.write('</body>');
newwin.document.write('</html>');
}
</script>
</head>
<body>
<a href="yourimagehere.jpg" onclick="writeimg('the title is here','250','110','yourbiggerimagehere.jpg');return false"><img src="yoursmallimagehere.jpg" border="0" width="50" height="50"></a>
</body>
</html>
the popup window opens up centered on the users screen, and the width and height of the popup is defined from the link, along with the title

kraftomatic
03-07-2005, 06:18 PM
Great, that worked.

Thanks.

glenngv
03-08-2005, 04:30 AM
You may also want to check this out. This script automatically detects the size of the image so you don't need to pass it.

http://www.codingforums.com/showthread.php?t=9836



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum