View Full Version : Writing an image into a popup window

07-08-2002, 11:35 PM
i'm using the script below to open a new window with a larger picture of a thumbnail, but when i click on the link it doesn't load the image into the window. anybody see any errors in my script?

<script language="JavaScript">
function opennew(img,xWidth,yHeight) {
// path, width and height as arguments
var msgWindow = window.open('','FullSize','Width=' + xWidth + ',Height=' + yHeight + 'resizable=no');
var page='';
<a href="#" onClick="opennew('img/800-lg.gif',350,350);">Open larger picture</a>

07-08-2002, 11:45 PM
This is what you are writing to the new window:

var page='';

an empty string.

Here is one I wrote a long time ago. You can modify it as needed:

<title>Popup Image Viewer</title>
<script type="text/javascript">
function imageView(imgFile,imgTitle,imgWidth,imgHeight,winPosX,winPosY){
preview = window.open("", "","resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width="+imgWidth+",height="+imgHeight+",left="+winPosX+",top="+winPosY+"");

preview.document.write('<html><head><title>'+imgTitle+' - Click to close - <\/title><\/head>'
+'<body onBlur="self.focus();" marginWidth="0" marginHeight="0" topmargin="0" leftmargin="0">'
+'<a href="javascript:self.close()">'
+'<img border="0" alt="Image loading please wait...." src="'+imgFile+'" width="'+imgWidth+'" height="'+imgHeight+'">'
// -->
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<!--// Parameter list as follows:
Image File
Title of Image
Width of Image
Height of Image
Window Position X coordinate
Window Position Y coordinate
<a href="javascript:imageView('images/australia08.jpg','Australian Limestone Desert',427,277,50,50)">
<img src="images/australia08thumb.jpg" width="84" height="55" border="0" alt="Click for larger image"></a>
<a href="javascript:imageView('images/australia11.jpg','Downtown Perth Australia',420,274,50,50)">
<img src="images/australia11thumb.jpg" width="84" height="55" border="0" alt="Click for larger image"></a>

07-08-2002, 11:47 PM
ds.write('<HTML><HEAD><TITLE>your title</TITLE></HEAD>');
ds.write('<BODY><IMG src="'+ yoursource + '"></BODY></HTML>);

07-09-2002, 12:11 AM
well, the only thing that you need to write is:

<a href="javascript:void(0);" onclick="window.open('standing.jpg','');"> salam </a>

I thought that the name of your picture is Standing.jpg
It's no need to open a window, you open a picture inside of a window from the begining!

Something else, don't use "href=#", coz if you have lot's of pictures and for all of them you put this, then suppose that youre page is an scrollable page and you're on picture 100th, by clicking on that, you'll come back to the begining of the pag, coz # means the top of the page, and I don't think it's what you like!