Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh parent window from child window using javascript

I am opening new pop-up page in new window. Now When I am pressing a html input button from child window, I want to close this child window then I want to refresh the parent window. How I can do using javascript?

Can you anyone suggest me the solution?

like image 685
Abhishek B. Avatar asked Jan 12 '11 10:01

Abhishek B.


People also ask

How do you refresh the parent window in closing the child?

In the HTML markup of the Child page we need to place the JavaScript function RefreshParent which is called attached to the browser onbeforeunload event. Thus when the Child page popup window is closed the parent page is refreshed.

How do I transfer data from child window to parent window?

From a child window or a small window once opened, we can transfer any user entered value to main or parent window by using JavaScript. You can see the demo of this here. Here the parent window is known as opener. So the value we enter in a child window we can pass to main by using opener.

How do you find the parent element in a child window?

You just need to prefix “ window. opener. ” and write the same code that you will write in the parent window's HTML page to access its elements.

How to refresh the child window from the parent?

but function refreshing my child window.. When opening your child window from the parent, remember the return value in a variable somewhere: var childWindow = window.open (/* ... */); Note that some browsers will prevent access to childWindow.location.reload if the parent and child aren't loaded from the same origin.

How to open a popup window (child window)?

To open a popup window (child window) , i used this show_billing_order_form call back , To refresh the child window , i add one refresh icon in my parent window , To refresh the child window , in that refresh icon onclick i called refresh_my_child_window ,

How to refresh the child window in Salesforce?

To open a popup window(child window) , i used this show_billing_order_form call back , To refresh the child window , i add one refresh icon in my parent window , To refresh the child window , in that refresh icon onclick i called refresh_my_child_window , but function refreshing my child window.. javascript.

How to add a new record to a child window?

Open child window using the script on your parent page (you already have it there). 2. Get rid of the code that checks if the window is closed or not. You don't need it, in any way. 3. When you are done with adding a new record from you child window call these statements:


2 Answers

try something like this:

function closeAndRefresh(){
  opener.location.reload(); // or opener.location.href = opener.location.href;
  window.close(); // or self.close();
}
like image 161
oezi Avatar answered Sep 17 '22 19:09

oezi


you could try this in you child window:

function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)

 {
    window.opener.progressWindow.close()
  }
  window.close();
}
like image 24
Robert Johnstone Avatar answered Sep 20 '22 19:09

Robert Johnstone