• Welcome to Valhalla Legends Archive.
 

Client-Side variables and such

Started by KrAzY_NuK, October 22, 2004, 03:33 PM

Previous topic - Next topic

KrAzY_NuK

I'm developing a small web-app at work, and I haven't really done a lot of web development.

Suppose you had this scenerio:
Main window (a) opens a new window (b) via "window.open()"
In window (b) i have a form that i want filled out, and i want the information returned to window (a)

is this at all possible?
i imagine i can refresh window (a) after window (b) has hit submit and get the data from the server.  I was just hoping there was a way that I wouldn't have to go back to the server for it.

Thanks!

j0k3r

This probably can (and should) be done another way, why do you need to open a new window and send information back to the old one?
QuoteAnyone attempting to generate random numbers by deterministic means is, of course, living in a state of sin
John Vo

KrAzY_NuK

That's what seemed like the easiest thing to do at the time.  The web-app is going to be used to recycle services on servers, or actual servers themselves.  It will also allow a user to setup a schedule, or run the chosen operation at that moment.

I figured that logically seperating everything would make sense, and i wanted to keep all of the information available on that one page without cycling through a bunch of pages

The code can be found at:
http://home.cc.umanitoba.ca/~umbewcyk/webapp.zip

Grok

Sure it's possible.  Window B is a child window of Window A.  In Javascript, use the .parent property to reference the (A) window.  Create a javascript function in Window A's code that accepts values from the caller.  In your (B) code, call Me.parent.YOURFUNCTION(parameters) to pass back what (A) needs to know.

MyndFyre

Quote from: Grok on October 24, 2004, 12:40 PM
Sure it's possible.  Window B is a child window of Window A.  In Javascript, use the .parent property to reference the (A) window.  Create a javascript function in Window A's code that accepts values from the caller.  In your (B) code, call Me.parent.YOURFUNCTION(parameters) to pass back what (A) needs to know.

I don't believe that would work, at least cross-browser.  The window.parent property is supposed to refer to the window containing a frameset, if one exists.

However, I recently set up something similar using Flash in the second window.  Basically, I set a function in the second window:

Second window Script:

var __parentFunc;
function doSetParentFunctionCall(ParentFunc) {
  __parentFunc = ParentFunc;
}


First page:

var childWindow;
function __onLoadHandler() {
  childWindow = window.open([i]parameters[/i]);
  childWindow.doSetParentFunctionCall(doProcessData);
}

function doProcessData(x, y)
{
  // ,,,
}


The flash movie then called:


javascript:__parentFunc(x, y);


to call the parent function.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

KrAzY_NuK

#5
cool cool!
I'll try those out and see what goes from there.

I don't think I need to worry about cross browser.  Everybody here should be using IE because they like to keep things *standard*.

*Edit:  I've tried both methods at *still* can't seem to get anything to work   :(

Grok

Quote from: KrAzY_NuK on October 25, 2004, 09:02 AMI don't think I need to worry about cross browser.  Everybody here should be using IE because they like to keep things *standard*.

Good one!  Haha.  I get it!

KrAzY_NuK

i figured it out!

window (A) has the following:

      function show( newVal )
      {
        alert( newVal )
      }
      function add()
      {
        var win = window.open( "add.asp" );       
        return;
      }


and window (B):

      function add()
      {
        opener.show(document.getElementById("add").value);
        window.close();
      }


so when i click the "ADD" button in window (B) it calls the function add() which runs the function show() from the calling page.

This is great!   Thanks so much guys!