 |
| HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 3rd, 2003, 11:28 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What is wrong in my HTML-code.....??????
<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*
|
|

September 4th, 2003, 04:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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:
Code:
<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
|
|

September 8th, 2003, 05:54 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 :D
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)
|
|

September 8th, 2003, 06:34 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

September 8th, 2003, 11:31 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|
|

September 9th, 2003, 02:36 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 " " 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  )
|
|

September 9th, 2003, 05:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
No problem Burton, glad it does what you want :D
To put the link under the picture, I would add a simple <br> between the <img> and <a> tags.
Code:
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
|
|

June 21st, 2004, 03:30 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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/ce...s/3sc_foto.htm
thanks,
ella
|
|

June 21st, 2004, 06:33 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
<><
|
|

June 21st, 2004, 07:35 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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,heig ht=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
|
|
 |