 |
| 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
|
|
|
|

November 5th, 2003, 04:38 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Button to replace close window text
Hi folks,
Can anybody help to solve this problem?
I have problems solving this code for a close window button to be shown instead of just ordinary text linked:
<!--
function showFullImage(sImageName)
{
winNew.document.write("<a href='#' onclick='window.close()'; >Close Window / Fenster Schliessen / Fermer fenêtre</a>");
}
// -->
I thought of something like this:
winNew.document.write("<a href='#' onclick='window.close()'; >'input type='button' value='close window' Close Window / Fenster Schliessen / Fermer fenêtre</a>");
p.s. The code above mustn't be amended much, because i have several photos needing this same function. Thats why i cant just do a simple code for each separate photo. The link works anyhow, but just without the button.
|
|

November 5th, 2003, 06:27 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
You can't use a button inside a <a> tag and expect the click of the <a> tag to fire.
Instead, write the click handler for the button directly, without an <a> tag (untested):
winNew.document.write("<input type='button' onclick='window.close()'; value='Close Window / Fenster Schliessen / Fermer fenêtre / Venster Sluiten'");
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 5th, 2003, 01:34 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Nope, didnt work.
I think the <a href='#' onclick='window.close()'; >
needs to be on to refer to this line below:
<a href="#" onclick="showFullImage('PHOTO.jpg');"><img border="0" src="PHOTO.gif" width="171" height="129">
</a>
(several photos amongst this, thats why variable at top to save lines)
I would appreciate another reply if possible..... thanks :)
|
|

November 5th, 2003, 01:54 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Quote:
quote:Originally posted by Imar
Hi there,
You can't use a button inside a <a> tag and expect the click of the <a> tag to fire.
Instead, write the click handler for the button directly, without an <a> tag (untested):
winNew.document.write("<input type='button' onclick='window.close()'; value='Close Window / Fenster Schliessen / Fermer fenêtre / Venster Sluiten'");
|
Just missing the closing > at the end of the string
Code:
...Venster Sluiten'>");
--
Joe
|
|

November 5th, 2003, 03:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Yep, thanks Joe. That was the problem. I guess that's what you get when you try to "program" from within a text area... ;)
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 6th, 2003, 07:39 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I appreciate the team work folks, but still doesnt work :(
The image now pops up in full window without any close link.
Here I post the code again, for I think the HREF# has to be within the code:
function showFullImage(sImageName)
{
var winNew = window.open("about:blank", "new", "fullscreen=yes", "scrollbars=yes");
winNew.document.write("<img border='0' src='" + sImageName + "'><br><br>");
winNew.document.write("<a href='#' onclick='window.close()'; >Close Window</a>");}
// -->
<a href="#" onclick="showFullImage('DIFFERENT PHOTOS.jpg');">
<img border="0" src="DIFFERENT PHOTOS.gif" width="172" height="129"></a>
Cheers !
(p.s. If possible, can you please also include the variable for the X to appear on the window on top right corner to close window aswell ;))
|
|

November 6th, 2003, 07:47 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What browser are you using? The code runs fine here.
I get the image in a new, full screen window, with a Close Window link beneath it. Is the image you're displaying too large, so it fills the entre screen hiding the Close link?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 6th, 2003, 07:52 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi again Imar,
Browser: IE6; no problems there....
I posted my link which actually does work.... all i would like is to have a button instead of a text-link (plise... :), as mentioned in my first post.
Thx for your time and effort....
|
|

November 6th, 2003, 08:15 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
My initial solution should work (provided you added the additional > to the code):
var winNew = window.open("about:blank", "new", "fullscreen=yes", "scrollbars=yes");
winNew.document.write("<img border='0' src='" + sImageName + "'><br><br>");
winNew.document.write("<input type='button' onclick='window.close()'; value='Close Window / Fenster Schliessen / Fermer fenêtre / Venster Sluiten'>");
This runs fine on my machine. When you look at the source of the new window, you'll see this:
<img border='0' src='YourImage.jpg'><br><br><input type='button' onclick='window.close()'; value='Close Window / Fenster Schliessen / Fermer fenêtre / Venster Sluiten'>
which looks fine to me.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 6th, 2003, 08:19 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
are you saying this doesn't work for you?
function showFullImage(sImageName)
{
var winNew = window.open("about:blank", "new", "fullscreen=yes", "scrollbars=yes");
winNew.document.write("<img border='0' src='" + sImageName + "'><br><br>");
winNew.document.write("<input type='button' onclick='window.close()' value='Close Window / Fenster Schliessen / Fermer fenêtre / Venster Sluiten'>");
}
// -->
|
|
 |