Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload parent page with parameter

I have the following javascript code that runs when a page is closed.

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

Is there a way to pass a paramenter to the page that calls this closed page ?

like image 675
Lucas_Santos Avatar asked Apr 28 '26 07:04

Lucas_Santos


2 Answers

If you want to close popup and reload parent page, You should use this.

window.opener.location.href='/pageurl.html?id=1'
window.close();
like image 136
Erdinç Özdemir Avatar answered Apr 29 '26 22:04

Erdinç Özdemir


The javascript variable window.parent should let you access to any parameters of the parent of the popup.

window.parent.reload();

from inside the popup should work.

As for the parameter

window.parent.variableName = 'Hello World!';

will create a variable name variableName in your parent.

So inside the parent, you will be able to do

alert(variableName);

and have an alert with the content 'Hello World!';

like image 23
Hipny Avatar answered Apr 29 '26 21:04

Hipny