File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a function from another window

 
Jos� Miguel Velasco
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It works.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic