wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Calling a function from another window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Calling a function from another window" Watch "Calling a function from another window" New topic
Author

Calling a function from another window

Jos� Miguel Velasco
Greenhorn

Joined: Dec 17, 2004
Posts: 2
I'm trying to make something like this:

I have an HTML page with Javascript. By clicking a button, another window is opened in order to allow data to be entered. I want this data to be updated in a data base (server side is PHP and MySQL), the secondary window be closed and the first window be refreshed with the new data.

How can I call a Javascript function in the first window in order to reload it when the secondary window is closed?

In the first window, a refreshing function is already coded and put as the onChange event of a SELECT element. It would be easy for me to simulate by code in the secondary window the SELECT's onChange event, but I'm afraid I can't. I'm able to get a reference in the secondary window to the SELECT element, but I have tried to execute the handleEvent method and it doesn't work.

Anybody can give any idea? Thanks in advance.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you can call a function from the child window by adding the window.opener object to it.

window.opener.FUNCTION()

You can reload the page with

window.opener.reload();

Eric
Jos� Miguel Velasco
Greenhorn

Joined: Dec 17, 2004
Posts: 2
Thanks. It works.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling a function from another window