RE: UPDATE: Javascript: in popup how to REPLACE image with modified image name

by "Micah R. Condon" <micahc(at)webdezyne.com>

 Date:  Sat, 12 Jan 2002 20:13:17 -0700
 To:  "'Jay Smith'" <jay(at)JaySmith.com>,
"'hwg-techniques'" <hwg-techniques(at)hwg.org>
 In-Reply-To:  JaySmith
  todo: View Thread, Original
You can create a javascript in the popup window that can be triggered by any
normal event (click, mouseover, etc.), but it just can't run inline while
the document is being written

-----Original Message-----
From: owner-hwg-techniques(at)hwg.org
[mailto:owner-hwg-techniques(at)hwg.org]On Behalf Of Jay Smith
Sent: Saturday, January 12, 2002 3:10 PM
To: hwg-techniques
Subject: UPDATE: Javascript: in popup how to REPLACE image with modified
image name


UPDATE:

(original text at bottom of this message)

After several hours of further research on the web and experimentation
I have come to the conclusion that (in at least Win95 NS 4.7x and IE
5.x) it is not possible to use the Javascript "writeln" method to
create a popup window THAT _THEN_ (in the pop-up) EITHER CONTAINS A
JAVASCRIPT OR REFERS TO AN EXTERNAL JAVASCRIPT.

Notice that I am using "writeln" and not "document.writeln" to make it
usable in a broader range of browsers.

I found one web reference in which an individual stated that it was
not possible in NS 4.7.x to use an EXTERNAL Javascript in a
dynamically created window.

At the same time, I found another web reference on a well-known
Javascript site which offers a script that DOES write an INTERNAL
Javascript.  I was not able to get this method to work in my browsers.

I would be interested in hearing from anybody that has found a way to
make this work.

In the end, I completed my project by:

  a) Putting both image filenames into the original/source HTML file
(though consumes a lot more space.

  b) In the pop-up, I was not able to use a Javascript to show the
larger image (because the pop-up content was dynamically created by a
Javascript), thus I used simple a HTML A link to show the image in the
same pop-up window -- however that means that I lose the text, 'close'
link, etc.

If anyone is interested, the final result can be seen at
http://www.JaySmith.com/Lists/Faroe/Stamps-1.html -- clicking on one
of the cameras will give you the pop-up/.

In summary, I CANNOT BELIEVE that the "simple" thing I wanted to
accomplish seems so difficult, if not impossible, at least in browsers
of a certain age.

Jay

======

Hi,

Members of this list were very kind to help me come up with the
Javascript below.  It opens a pop-up window (only if the user desires
to see an image), writes some content into the pop-up, and puts in an
image using a variable "imgName" that was passed to it from the web
page that called this Javascript. That all works great!  (Thanks!)

An example of the original HTML page which calls the first Javascript
can be seen at http://www.JaySmith.com/Lists/Faroe/Stamps-1.html --
clicking on one of the cameras will run the Javascript and give you
the pop-up.

NOW, in the POP-UP, I want to enhance it by adding a link or button,
in the pop-up, that the user can click to see a larger version of the
image, in the same window.

I hope that this is clear.  I am finding it hard to explain.

1) I assume that this has to be done by having the HTML in the pop-up
(which was written by the below Javascript) call ANOTHER Javascript.

2) The value of "imgName" that was passed to the FIRST Javascript was
something like the following (note that the Javascript prepends it
with the front part of the URL):

     /Lists/Faroe/Stamps/0001a_sc0007-20_110126_r_m.jpg
  >>>> Note that the filename ends with "_m.jpg"

  >>>> The value of "imgName" that I WISH TO PASS to the SECOND
Javascript to show the larger image is the SAME, except for the ending
"_l.jpg"

     /Lists/Faroe/Stamps/0001a_sc0007-20_110126_r_l.jpg

3a) How do I use Javascript (if at all?) to change the value of
"imgName" by replacing the ending "_m.jpg" with "_l.jpg" ?

3b) How do I put that new value into a new variable "imgLargeName" ?

   (I am trying to avoid having the _original_ HTML page contain both
image names because there are a LOT -- and they are also repeated
because they are passed by a form (with EACH Buy It button) to a
shopping cart process -- of them and the pages are already much too
large.)

   (I am also trying to avoid having two links on the original HTML
page for smaller and larger images.)

4) In the pop-up, when the link to view the larger image is clicked, I
wish to use the CURRENT pop-up window to display the larger image and
accompanying text.  I am assuming that I will write content to the
window, using a second Javascript, in the same manner as I did using
the first Javascript.

5) Or is there some other way??

HERE IS THE FIRST JAVASCRIPT...

<!--
function JSAREP (imgName)
{
var opts =
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,r
esizable=yes,width=720,height=700";

var win = window.open ("", "_jsa", opts);

with (win.document)
{
writeln ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "hmpro6.dtd">');
writeln ('<html>');
writeln ('<head>');
writeln ('<title>Jay Smith &amp; Associates Scandinavian
Philately</title>');
writeln ('<link rel="stylesheet"
href="http://www.JaySmith.com/jsa.css">');
writeln ('</head>');
writeln ('<body topmargin="0">');
writeln ('<table width="663" cellpadding="0" class="LOGO" align="left"
border="0">');
writeln ('<tr valign="top">');
writeln ('<td class="LOGO"><img
src="http://www.JaySmith.com/graphics/jsa.gif" alt=" " width="473"
height="110" border="0"></td></tr>');
writeln ('<tr valign="top">');
writeln ('<td height="4" class="TOPSEPARATOR">&nbsp;For Quality
Scandinavian Philately</td></tr></table>');
writeln ('<p style="clear: both">This is a representative image of the
item.<br>(Image may take a moment to appear.)</p>');
writeln ('<p><a href="javascript:window.close()">Close</a> this image
window (optional).</p>');

##### THE NEXT LINE USES THE imgName variable

writeln ('<img
src="http://jsa.ViewImage.net/images/web',imgName,'">');
writeln ('<p><a href="javascript:window.close()">Close</a> this image
window (optional).<br>&nbsp;</p>');
writeln ('</body>');
writeln ('</html>');
close ();
if (window.focus) {win.focus()}
}
}
// -->


--
Jay Smith

e-mail: Jay(at)JaySmith.com  mailto:Jay(at)JaySmith.com
website: http://www.JaySmith.com

Jay Smith & Associates
P.O. Box 650
Snow Camp, NC  27349  USA

Phone: Int+US+336-376-9991
Toll-Free Phone in US & Canada:
	1-800-447-8267
Fax: Int+US+336-376-6750

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.