admin管理员组

文章数量:1278792

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 ?

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 ?

Share Improve this question edited Jul 31, 2012 at 14:59 Frank Visaggio 3,71210 gold badges36 silver badges71 bronze badges asked Jul 31, 2012 at 14:52 Lucas_SantosLucas_Santos 4,74018 gold badges74 silver badges121 bronze badges 1
  • are you in a popup or in an iframe? – Hipny Commented Jul 31, 2012 at 14:54
Add a ment  | 

2 Answers 2

Reset to default 6

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

window.opener.location.href='/pageurl.html?id=1'
window.close();

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!';

本文标签: javascriptReload parent page with parameterStack Overflow