?
Solved

window.opener from SECONDARY Popup

Posted on 2003-03-13
7
Medium Priority
?
363 Views
Last Modified: 2011-10-03
Folks,
  I have a Main window (MainWin) that calls window.open() to open up a child popup window (UserInfoWin). This works fine. That Popup window spawns a SECONDARY popup (UserEditWin) via another call to window.open() AND THEN UserInfoWin closes itself using self.close();. The user then works with the data in UserEditWin, and when they click a link, I would like the following to happen:
 
  I would like UserEditWin to be able set a value in a form (myForm) in the MainWin, and then submit that form. If it was UserInfoWin that was setting the values then I could just call window.opener.myForm.submit(), but it is not the direct opener of the window (UserInfoWin has closed).
 
  I have tried referring to this window by name, AKA:
  <A HREF='#' ONCLICK='Javascript:MainWin.document.myForm.ok.value=1;MainWin.document.myForm.submit();return true;'>Click here to submit</A>
  But apparently this MainWin is not referancable globally because I get a "Not Defined" error.

  Any ideas on how to get this working? How can I refer to windows from other (unrelated) windows?

thanks in advance
0
Comment
Question by:Acorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 

Expert Comment

by:EEK
ID: 8131230
Pretty similar thing handled here: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20549420.html

"opener" is the keyword you need.

-EEK
0
 

Author Comment

by:Acorn
ID: 8131283
EEK,
  I'm not sure you read all of my question. The opener has been closed. Again, it's three windows, I want to control the MainWin from a SECONDARY popup, not the FIRST popup.

1) MainWin->User Click->Popup UserInfoWin
2) UserInfoWin->Click->Popup UserEditWin;Close UserInfoWin
3) UserEditWin->Click->Set Value on form on Mainwin;Submit Form on MainWin.

Thanks
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8131290
EEK,
These 2 are completely different questions, please read the question more carefully.

Acorn,
Are you sure you gave the main window the name 'MainWin'?

If it doesn't work, try having a hidden form on the first popup, passing the variable to the hidden form, then having the info on the hidden form passed the the main window.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Acorn
ID: 8131386
lil_puffball,
  I am pretty sure I named the main window correctly. To test it I added an ONCLICK='alert(window.name);' to a link on the MainWin page and got "MainWin" in the alert box.

  I'd try passing the variables back and forth, but I'm not ALWAYS guaranteed that the user will go from MainWin->UserInfoWin->UserEditWin. They might go directly from MainWin->UserEditWin based on where they are coming from in the site. (Sorry to throw out another wrench!).

  I'm a little confused as to why I cannot refer to MainWin directly by name. Doesn't seem natural to me. Is this normal? IE 5.5....

0
 
LVL 12

Accepted Solution

by:
lil_puffball earned 60 total points
ID: 8131627
Hmm. Well, why don't you call the function to open UserEditWin from the main page? e.g.

<a href="#" onClick="window.opener.open_third_popup()">

and on the main page:

function open_popup() {
window.open('url.htm','UserEditWin')
}
0
 

Author Comment

by:Acorn
ID: 8131724
Ack!! I think you meant on the main page:

function open_third_popup() {
...

But I get your drift. That is very doable. Not elegant as I'd like, but it sure gets the job done.

Any idea why I couldn't refer to this window name directly? Are you not allowed to refer to window names like that? MainWin isn't a reserved name or something is it??

0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8132588
Acorn,
so sorry, I did do a typo! :)
But no, I'm sure MainWin isn't a reserved word. Three things tell me so--Usually reserved words contain only lowercase letters, second of all they are usually only 1 word (e.g. window, document, top, etc.) and third they usually contain full words (so it'd probably be MainWindow rather than Win.) I'm not too sure why you can't reference windows that way. Perhaps when you open more than one window they don't have a 'connection' anymore, so they can't reference each other, much like you can't reference any other webpages open on the user's browser unless you directly opened them. The reason for this may be:
-What if you opened a window for the user that you didn't know what would be on it? And let's say your window is called MainWin. But what if that opened page is also called MainWin? (For example if the code said self.name='MainWin') And then from that page the user opened a third popup that made a reference to MainWin? How would the computer know which window it referred to??? Anyway, just my speculations...
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question