Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1443 How else can I pop-up a window the same size as the image it contains?

irt.org | Knowledge Base | JavaScript | Window | Q1443 [ previous next ]

Q1443 How else can I pop-up a window the same size as the image it contains?

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: /p>

<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


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.