RE: Passing an object as a paramter between windows

by "Brett Errington" <brett(at)opensearch.com>

 Date:  Mon, 27 May 2002 09:16:58 +0800
 To:  <hwg-techniques(at)hwg.org>
 In-Reply-To:  hilma
  todo: View Thread, Original
You put your question all the way down the bottom... prolli why no one
has replied yet lol :)

Anyway you can communicate between windows so you can just make a copy
of the object from one to another. For example from the original window
you could do something like this:

openWindow.Allphotos = Allphotos;

Or from the new window you could do this:

Allphotos = window.opener.Allphotos;

(someone correct me if I missed something out here)

However you can also pass information along the URL string as parameters
like so:

http://www.something.com/default.html?height=300&width=200

Then in the new window you can retrieve them with some fairly simple JS.
If you go to http://imptech.net he explains this method (even though
it's using Flash you can still get the JS bit for normal HTML). Up to
you which way you choose. Hope this helps...

Later,
Brett

"That's a pain that will shorely linger, and that's no lie" - Ed Grimley


-----Original Message-----
From: owner-hwg-techniques(at)hwg.org [mailto:owner-hwg-techniques(at)hwg.org]
On Behalf Of Hilma
Sent: Sunday, 26 May 2002 10:52 PM
To: hwg-techniques(at)hwg.org
Cc: Brett Errington
Subject: Passing an object as a paramter between windows

Many weeks ago :-)
i was asking about passing parameters to a  new window.
And thanks to help from you people, i got it going successfully.

So now,  a full-size image is opened up in my "imageWindow"  (which i
call
'HHPhotoSingle.htm')  when you click on a thumbnail
http://mysite.freeserve.com/bbm/hagar/HH/HHVolBTCV.htm
------------------------------------------------------------------------
----
-------------------------------------------------
JS Code:
http://mysite.freeserve.com/bbm/hagar/HH/HH_Photos.js

function openWindow(contentURL,windowName,windowWidth,windowHeight) {
 widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;
 newWindow = window.open(contentURL,windowName,widthHeight);
 newWindow.focus()
}

//I've no idea what "windowName" is for, i think i can drop it as an
argument as it never changes, but this is not an issue for now

------------------------------------------------------------------------
----
-------------------------------------------------
http://mysite.freeserve.com/bbm/hagar/HH/HHVolBTCV.htm
Code in my HTML page defines the file name and path, the title, and the
window dimensions:

<a href="javascript:openWindow(HHPhotoSingle.htm?Pic=VolBTCV/BTCV01,Pete
our
esteemed leader','myNewWindow',800,600)">
      <img alt=".........."/>
    </a>
------------------------------------------------------------------------
----
-------------------------------------------------

Code in my HHPhotoSingle.htm :
http://mysite.freeserve.com/bbm/hagar/HH/HHPhotoSingle.htm

var mytext =location.search.substring(1);
var i = mytext.indexOf("=");
var j = mytext.indexOf(",");

   photoname = mytext.substring(i+1, j);
   phototitle = mytext.substring(j+1);

   document.write("<h1>" + unescape(phototitle) + "</h1>");
   document.write("<img src='images/" + photoname + ".jpg' />");

------------------------------------------------------------------------
----
-------------------------------------------------
------------------------------------------------------------------------
----
-------------------------------------------------

However:
I have now advanced ;-)
to using associative arrays;

My (offline) js now has an array called AllPhotos, such that i have
'photo'
objects, all about one photograph, things like:

AllPhotos.BTCV08.file
AllPhotos.BTCV08.path
AllPhotos.BTCV08.title
AllPhotos.BTCV08.alt
AllPhotos.BTCV08.width
AllPhotos.BTCV08.height

I know i need to use
AllPhotos.BTCV08.width
AllPhotos.BTCV08.height
in the call to openWindow;

but is there any way, using Client-side scripting (I'm not yet advanced
enough for server-side!) that i can pass the BTCV08 *photo object* to
the
HHPhotoSingle.htm , via the openWindow call?

I can only see how to pass text strings, as i am currently doing;
but as a VB6 programmer, i like to think that i *can* pass an object (by
reference) to this new window.

However - my JS books and my JS knowledge are not up to it!

Any explanation and help much appreciated :-)


Hilma
---x---




----- Original Message -----
From: "Brett Errington" <brett(at)opensearch.com>
To: <hwg-techniques(at)hwg.org>
Sent: Sunday, May 05, 2002 2:55 PM
Subject: RE: Passing paramters between windows


> You can do this three ways (well probably more but these are the first
> that come to mind).
........
>
> If you need more help let me know.
>
> Later,
> Mr Brett
 Yes please ;-))

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