You are here: irt.org | FAQ | JavaScript | Window | Q1443 [ previous next ]
It is usually difficult to avoid the margins browsers will automatically place around your image. If you know the size of the image you wish to place in your pop-up window, the alternative to using the <IMG src="">-tag is using the <BODY background>-tag. Open a window with the size of your image, and create a html-document on-the-fly with the image as a background.
Place this function inside the <HEAD> section of your page:
<script language="JavaScript">
function picture(picgoal,picname) {
PicWin=window.open("",picname,'status=0,scrollbars=0,resizable=0,width=100,height=100,screenX=50,screenY=50,top=50,left=50');
PicWin.document.open();
PicWin.document.writeln('<html>');
PicWin.document.writeln('<head>');
PicWin.document.writeln('<title>Picture in a window</title>');
PicWin.document.writeln('</head>');
PicWin.document.writeln('<body background="'+picgoal+'">');
PicWin.document.writeln('</body>');
PicWin.document.writeln('</html>');
PicWin.document.close();
}
</script>Then this as the link:
<A HREF="http://www.picture.gif" onClick="picture(this,'picturewindow'); return false">Click here</A>
Submitted by Eric Rietzschel