File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to call parent window id in child window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to call parent window id in child window" Watch "How to call parent window id in child window" New topic
Author

How to call parent window id in child window

sravani gogineni
Ranch Hand

Joined: Feb 09, 2011
Posts: 33
Hi

I need to call parent hidden field in child window. How do I do that in JavaScript?
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

looks like there is no other way than sending the data from parent while opening the child window. They cannot be in sync until there is request to your server(in sync or async using ajax) to update/read parent and populate the same in child.


Have Fun with Java
little,little.. little by little makes a lot..
sravani gogineni
Ranch Hand

Joined: Feb 09, 2011
Posts: 33
could you please tell me how do i send parent data to child window when i open a child window?
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

what is there in it? Am i missing something? Am on the same page as yours..

Anyways, it is same as how you get the data in your parent read, it from the infrastructure of your application. It can be from any scope - the application (retrieve from the static variables in child window), session(retrieve from the session which you would set before opening child window), request (same from request). how to set these values in different scope is the actual story. Say if you are not processing any request in the server side to open the (somewhat called static JSP) child then you can just put it in the URL (like childURL?parameterName=value) but it is not recommended for security reasons and not a good practice.
jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 93
sravani gogineni wrote:Hi

I need to call parent hidden field in child window. How do I do that in JavaScript?


Do you want to send the field or the field value (content)??
If you want to pass the field content, I think that you would must to try passing the parameter by url similar to this
I think you won't have problems if the new windows is a popup (child)

Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Thanks jhon, i was having the prepective that the child is a popup/newwindow being opened from javascript
sravani gogineni
Ranch Hand

Joined: Feb 09, 2011
Posts: 33
I need to place a hidden field in main page and child page for storing the session id. i want to compare both and see if they are equal then proceed else go to login page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

sravani gogineni wrote:I need to call parent hidden field in child window. How do I do that in JavaScript?

You don;t "call" fields so what is it you are really trying to do?

Perhaps change the value of the field from the child? If so, you can find a reference to the parent window in the opener variable.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sravani gogineni
Ranch Hand

Joined: Feb 09, 2011
Posts: 33
Bear Bibeault wrote:
sravani gogineni wrote:I need to call parent hidden field in child window. How do I do that in JavaScript?

You don;t "call" fields so what is it you are really trying to do?

Perhaps change the value of the field from the child? If so, you can find a reference to the parent window in the opener variable.


I tried using this :
var test =window.opener.document.getElementById('field1').value;
alert(test);

but the alert box is not seen
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

What does the JavaScript console show? Any errors?

Check each part of your reference chain to make sure that things are evaluating to what you think they are supposed to.
sravani gogineni
Ranch Hand

Joined: Feb 09, 2011
Posts: 33
JS console ? how do i look at it? As of now i dont see any errors in the left hand corner of the window.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

If you are writing JavaScript you need to become familiar with the tools necessary. For Firefox, download Firebug. Chrome, Safari and IE8/9 come with their own debuggers.
sravani gogineni
Ranch Hand

Joined: Feb 09, 2011
Posts: 33
I dont see any errors in the console.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

Start checking each step in your reference. Does each step evaluate to what you think it does?
 
Consider Paul's rocket mass heater.
 
subject: How to call parent window id in child window