Subject: What is wrong in my HTML-code.....??????
Posted By: Burton Post Date: 9/3/2003 11:28:31 AM
<body>
<p>
<a href="picture.jpg" OnClick="window.open('picture.jpg', 'big', 'fullscreen=yes', "JavaScript:onClick=window.close()">Close Window); return false"><img border="0" src="picture.jpg" width="172" height="129"></a>
</body>

[if you take the ,"JavaScript:...Close Window) section out, the code works]... does the window.close() need to be after the brackets of <img border instead? I need just a CLOSE WINDOW link in the POP-UP IMAGE.

Do I need to CLOSE a POP-UP IMAGE with something like this instead?:
<a href="javascript:window.close()">>img border="0" src="imagename.gif"></a>

Please correct my code and post it here...... i am really desperate *HELP*


Reply By: pgtips Reply Date: 9/4/2003 4:17:42 AM
Oh Burton, you're getting in a bit of a mess here

So you want a thumbnail which, when clicked, opens a full-sized image in a new window right?  And you also want a "Close Window" link in that new window?

Your current problem is that the new window you're opening is just a JPEG not an HTML document.  Browsers know how to display JPEGs so that's no problem, but you can't put a javascript "Close Window" link in a JPEG.  You need to open a new HTML document and write an <IMG> tag and the "Close Window" link into it.  Something like this:

<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function showFullImage(sImageName)
{
   var winNew = window.open("about:blank", "new", "fullscreen=yes");
   winNew.document.write("<img border='0' src='" + sImageName + "'>");
   winNew.document.write("<a href='#' onclick='window.close();'>Close Window</a>");
}
// -->
</script>
</head>
<body>
<a href="#" onclick="showFullImage('picture.jpg');">
  <img border="0" src="picture.jpg" width="172" height="129">
</a>
</body>
</html>

Note that I only write out the basic <IMG> and <A> tags.  Browsers are very forgiving about displaying incomplete HTML but you may want to write out the full <html><head>...etc.

hth
Phil
Reply By: Burton Reply Date: 9/8/2003 5:54:45 AM
LOL.....sure, I'm in a damn mess! Thats why I appreciate the replys from you guys so much. Hope my problems will be solved soon, so I won't clutter with my basic errors any more

Are you sure I cannot include a CLOSE WINDOW within my pop-up image? There seems to be a lot of space under the popped-up image within the window.
See Joe's reply below, will that not work for me?
(I could change my JPEG to a GIF, JPG or BMP if that helps)

I do actually have an <IMG> tag in my pop-up IMAGE script and it works! (only 'close-window' missing, check out my HTML-code posted earlier)

Hope to receive your reply soon

p.s. If my problem cannot be solved via IMAGE POP-UP, could you kindly post me the basic code I need for pop-up via thumbnail to HTML (as you correctly realized, I need this approach via thumbnail for approx. 12 images)

Reply By: pgtips Reply Date: 9/8/2003 6:34:33 AM
Hi Burton,

Yes I saw Joe's reply, but that had the close window link in the parent page, not the pop-up window.

What's wrong with using the method I posted?  You get a full-size popup with the image and a close window link.  Isn't that what you wanted?

You can use the script I posted for as many images as you want, you just need to add extra <a> tags for each image, e.g.
<a href="#" onclick="showFullImage('picture.jpg');">
  <img border="0" src="picture.jpg">
</a>
<a href="#" onclick="showFullImage('picture2.jpg');">
  <img border="0" src="picture2.jpg">
</a>
...
<a href="#" onclick="showFullImage('picture12.jpg');">
  <img border="0" src="picture12.jpg">
</a>

Maybe I missed something, but I don't see what else you need...

rgds
Phil
Reply By: Burton Reply Date: 9/8/2003 11:31:12 AM
Sounds fine Phil, I'll test it tomorrow (time to go home now )
If you 'hear' nothing else from me, I'll have gotten your answer to work.
Thanks a dozen mate!

Reply By: Burton Reply Date: 9/9/2003 2:36:53 AM

Phil, thanks a lot. It works now.

Just a minor addition:
How do I put the CLOSE WINDOW neatly underneath the image? At the moment it is just joined onto the right-hand side of the image.
I suppose it needs "&nbsp;" adding, but I don't know where within the script!?

Thanks again for time spent on solving my problem (myself I was hours at it )

Reply By: pgtips Reply Date: 9/9/2003 5:17:03 AM
No problem Burton, glad it does what you want

To put the link under the picture, I would add a simple <br> between the <img> and <a> tags.

function showFullImage(sImageName)
{
   var winNew = window.open("about:blank", "new", "fullscreen=yes");
   winNew.document.write("<img border='0' src='" + sImageName + "'><br>"); // <== here
   winNew.document.write("<a href='#' onclick='window.close();'>Close Window</a>");
}


rgds
Phil
Reply By: ella Reply Date: 6/21/2004 3:30:27 AM
Dear Phil,

i have the same problem as burton, but i need a script to close the pop-up window by clicking on the showed image and not to the "Click to close" link.. where should i put onclick=close.window()???


i need it to this page: http://www.pote.hu/bioanal/ceepus/ceep/events/3sc_foto.htm

thanks,

ella
Reply By: Snib Reply Date: 6/21/2004 6:33:15 AM
var winNew = window.open("about:blank", "new", "fullscreen=yes");
winNew.document.write("<img border='0' src='" + sImageName + "' onclick='window.close()'><br>");

Try putting it in the <img> tag as shown above.

HTH,

Snib

<><
Reply By: ella Reply Date: 6/21/2004 7:35:16 AM
thanx,

i just solved it this way:

<script language="javascript" type="text/javascript">
<!--
function showFullImage(sImageName)
{
   var winNew = window.open("about:blank", "new", "scrollbars=no,resizable=no,menu=no,width=660,height=450");
   winNew.document.write("<a href='#' onclick='window.close();'><img border='0' src='" + sImageName + "'></a>");
   winNew.document.write("<title>Click to Close</title>")
}
// -->
</script>

ella
Reply By: rajaikram Reply Date: 10/13/2004 8:12:10 AM
dear i didn't find of my book HTML 4.01 Programmers Refrence Can you Please Help me to get my Book Code Thanks

raja ikram
Reply By: richard.york Reply Date: 10/13/2004 8:16:17 AM
HTML 4.01 Programmer's Reference was sold to Apress when the old Wrox went bankrupt. You can find it on their website, most likely at support.apress.com.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail

Go to topic 12978

Return to index page 86
Return to index page 85
Return to index page 84
Return to index page 83
Return to index page 82
Return to index page 81
Return to index page 80
Return to index page 79
Return to index page 78
Return to index page 77