Send update request to another page open in browser

I have page A that creates a window with page B.

Page B asks the user for some data, inserts it into the database, and then closes. After insertion, I try to automatically refresh page A (it can be like from A, seeing that B is closed, or using the function called by B itself before closing (or after?))

How can i do this?

0
source share
3 answers

JavaScript window.open()returns a link to an instance of an open window. You can use it to configure an event handler onunload, for example:

var hWndB = window.open('somepage.php'),
    hWndA = window.self;

hWndB.onunload = function(){ hWndA.location.reload(); }
+2
source

onunload window.opener. .

window.addEventListener('unload', function() {
   window.opener.location.reload();
}, false);

jquery, crossbrowser:

$(window).on('unload', function() {
   window.opener.location.reload();
});

onbeforeunload, .

, @CORRUPT : window.open() undefined null

+1

" B ":

//winb is global variable
winb=window.open(blah blah); //Existing: A opens B

window.setTimeout(checkWinB,1000);

function checkWinB() {
  if (winb.closed()) refreshMySelf();
  else window.setTimeout(checkWinB,1000);
}

"B A":

opener.rerfreshMySelf();
window.close() //Existing: B closes

refreshMySelf() . , , , AJAX,

function refreshMySelf() {
  location.reload();
}
0
source

All Articles