JavaScript, Web Development

JavaScript – Call Function from Parent Window

Another handy tip for JavaScript : Calling a function from Parent Window.

In a web application, there are times that when in a certain window, you’ve clicked a button. That button opens a new window.

Now that you are in a new window, there comes a time that you need to call a certain function from the parent window. Or you may want to change some form values.

In JavaScript, to open a new window:, windowName[, windowFeatures]);

Assuming you have this function from parent window:

function sampleFunction()
   //do some stuff
   alert("I did it!");

In your new window, we call it child window, you can call that function using the window.opener object.


Or even access form values like:

//this is in the child window

Of course it has been discussed thousand times before. Here is where i get it:

I posted it here today since I needed that very code in my project. And since I’m happy with the results, I share it with you. 🙂

Leave a reply

Your email address will not be published. Required fields are marked *