Author | Message | Time |
---|---|---|
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! | October 22, 2004, 8:33 PM |
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? | October 22, 2004, 8:42 PM |
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 | October 22, 2004, 9:04 PM |
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. | October 24, 2004, 5:40 PM |
Myndfyr | [quote author=Grok link=topic=9283.msg85926#msg85926 date=1098639619] 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. [/quote] 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: [code] var __parentFunc; function doSetParentFunctionCall(ParentFunc) { __parentFunc = ParentFunc; } [/code] First page: [code] var childWindow; function __onLoadHandler() { childWindow = window.open(parameters); childWindow.doSetParentFunctionCall(doProcessData); } function doProcessData(x, y) { // ,,, } [/code] The flash movie then called: [code] javascript:__parentFunc(x, y); [/code] to call the parent function. | October 24, 2004, 11:38 PM |
KrAzY_NuK | 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 :( | October 25, 2004, 2:02 PM |
Grok | [quote author=KrAzY_NuK link=topic=9283.msg86064#msg86064 date=1098712939]I don't think I need to worry about cross browser. Everybody here should be using IE because they like to keep things *standard*.[/quote] Good one! Haha. I get it! | October 25, 2004, 7:24 PM |
KrAzY_NuK | i figured it out! window (A) has the following: [code] function show( newVal ) { alert( newVal ) } function add() { var win = window.open( "add.asp" ); return; } [/code] and window (B): [code] function add() { opener.show(document.getElementById("add").value); window.close(); } [/code] 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! | October 25, 2004, 8:55 PM |