Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
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
 
Old November 5th, 2003, 04:38 AM
Authorized User
 
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

 
Old November 5th, 2003, 06:27 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old November 5th, 2003, 01:34 PM
Authorized User
 
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default


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

 
Old November 5th, 2003, 01:54 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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 &gt; at the end of the string
Code:
...Venster Sluiten'>");
--

Joe
 
Old November 5th, 2003, 03:05 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old November 6th, 2003, 07:39 AM
Authorized User
 
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old November 6th, 2003, 07:47 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old November 6th, 2003, 07:52 AM
Authorized User
 
Join Date: Aug 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old November 6th, 2003, 08:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old November 6th, 2003, 08:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

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'>");
}
// -->





Similar Threads
Thread Thread Starter Forum Replies Last Post
Window.close muthuprakash83 Javascript How-To 0 August 7th, 2006 12:35 PM
window.close() failing to...well...close! mheathcote Javascript How-To 2 October 31st, 2005 03:02 PM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
How do i close pop-up window?: window.close () Burton HTML Code Clinic 2 September 8th, 2003 05:40 AM
How to detect window Close (X) Button cyberjames2003 Javascript How-To 2 July 27th, 2003 08:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.