Click to See Complete Forum and Search --> : add a close window link to a pop up window


lorichaput
01-05-2003, 12:26 PM
What I need to know is how to add a close button or link into a pop up window (without using a separate .htm file for every pop-up)
ex:
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,resizable=0,width=300,height=300');");

}

then, in the body of the page it links an image to pop up a larger image

<a href="javascript:popUp('images/large/leaf.jpg')"><img src="images/thumbs/bw_leaf.jpg" width="200" height="199" name="large_bwleaf" border="0"></a>

With the pop-up window open with the new large image, it nees a "close this window" link.

Can you help?

pyro
01-05-2003, 12:52 PM
You won't be able to do it using that meathod, because all you are doing is opening an image file. You will either have to use individual files, or open your window differently.

David Harrison
01-05-2003, 01:00 PM
What I would do is have a submit button next to the image and when you click it have it open a pop-up window. Download the attachment to see what I mean.

David Harrison
01-05-2003, 01:01 PM
I forgot to mention, if you have more than one image you could use radio buttons to select which image you would like to enlarge.

Zach Elfers
01-05-2003, 02:53 PM
You could write some HTML code to the window so that the images would appear in an iframe, and below the iframe would be a close button. You can make a close button like this: <input type="button" onClick="self.close();" value="Close">

AdamGundry
01-05-2003, 03:44 PM
If I understand your question correctly, you can open a popup window like you originally suggested, then write HTML code into it like this:


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('about:blank', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300');");
eval("page" + id + ".document.write('<html header code><img src=\"" + URL + "\"><a href="javascript:window.close()">Close me</a>');
}


Modify the code in the second eval() to generate a page that fits what you want - I've included the close link. Sorry if the quotes in it are wrong, if there are errors you should be able to sort them out.

Adam