PDA

View Full Version : popup link


she
11-24-2004, 06:56 PM
i have the following code already working, but I want to add a link at the bottom of the page that opens that will enable the viewer to close it.

current code

<img src="url" onClick="window.open('url','mywindow',width=450,height=500')">

so what I have is a thumbnail of a picture that opens a new window when clicked, and display's the image full size.

what I want is a link inside the window that has the picture full size that will close that window.

so would i add something to the code i already have or do i need a seperate code?

thanks in advance :D

p.s. i just made these on photoshop to kind of illustrate what i want:
http://www.geocities.com/jameliae/sample2.gif
one of these thumbnails is clicked on which opens the new window

http://www.geocities.com/jameliae/sample1.gif
and then the link below the picture closes it..

Horus_Kol
11-24-2004, 07:36 PM
you need an onclick event in your close link:


<a onclick='self.close()'>Close</a>

she
11-25-2004, 04:46 AM
Originally posted by Horus_Kol
Please don't cross-post - you only need to ask a question once, and if you're patient someone will turn up with an answer.
you need an onclick event in your close link:


<a onclick='self.close()'>Close</a>


i wan't "cross-posting" i intended to move my post to a different category that related to my question, had you given me more time to delete the other one i would have.

and since i'm so impatient, i decided to go to another forum that acutally answers questions without insults, and found out that unlike your vague answer what i needed to do was make an html page for the image...
and then add this to it:
<a href="javascript:window.close() ;">close</a>


but thanks anyway

corey84
11-25-2004, 04:53 AM
You know it would have been better to leave your little "slap on the hand" at that instead of trying to insult a mod, and by the way HK's answer was in fact correct and does work

ohh well

she
11-25-2004, 05:10 AM
i wasn't insulting him, i was being insulted. based on the fact that i posted my question in the wrong place and then moving it apparently makes me impatient. i don't think that it is impatient to come to a forum in hopes of having your question answered after searching for it on your own for 2 hours. this is supposed to be a place where you can come to ask questions because you don't have answers, not a place to be insulted because you've asked them.

whatever, i don't know what it has to do with you, but this forum is less than informative and yes his answer was a correct one but not an answer to the question i was asking.

i dont even know why i'm having to explain myself here, all i wanted to do was post a question and have it answered.

coothead
11-25-2004, 05:46 AM
Hi there she,

actually it is not necessary to make an .html file for the image :)

you can do it sort of inline like this example....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>variable popups</title>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<base href="http://coothead.homestead.com/files/"/>

<style type="text/css">
/*<![CDATA[*/

div {
width:60px;
border:solid 1px #000;
}
div img {
width:50px;
height:50px;
border:solid 1px #000;
margin:3px;
}

/*//]]>*/
</style>

<script type="text/javascript">
//<![CDATA[

function popUp(w,h,image) {

h=h+30; /*this allows for close link height*/

var l=(screen.width-w)/2;
var t=(screen.height-h)/2;

var features="left="+l+",top="+200+",width="+w+",height="+h;

var mywindow=window.open('','',features);
mywindow.document.write('<html><title>'+image+'</title><body style="margin:0px;padding:0px;background:#000">'+
'<img src='+image+'><div style="text-align:center;margin:5px;">'+
'<a style="color:#fff"href="javascript:void(window.close())">'+
'close</a></div></body></html>');
mywindow.document.close();
mywindow.focus();
}

//]]>
</script>

</head>
<body>


<div>
<img src="dog.jpg"onclick="popUp(400,432,'dog.jpg')" alt=""/>
<img src="aaa.jpg"onclick="popUp(200,200,'aaa.jpg')" alt=""/>
</div>

</body>
</html>