I have a page that opens a modal dialog. After the operations done on dialog I want to refresh the opener page. But when I open the popup by using "openDialog" I cannot access to the opener by using window.opener on popup page. It appears "undefined" when I wanted to access. (I dont want to use "popup" method in this case. I want it to be a dialog by the way. using "popup" is my second plan.)
What is the best practice to get rid off this issue?
I have a page that opens a modal dialog. After the operations done on dialog I want to refresh the opener page. But when I open the popup by using "openDialog" I cannot access to the opener by using window.opener on popup page. It appears "undefined" when I wanted to access. (I dont want to use "popup" method in this case. I want it to be a dialog by the way. using "popup" is my second plan.)
What is the best practice to get rid off this issue?
Share Improve this question asked Jun 25, 2009 at 12:28 Ali ErsözAli Ersöz 16.1k12 gold badges51 silver badges64 bronze badges5 Answers
Reset to default 3Modifying parent data from modal dialog
Refresh parent window from modal child window
this was what i need that i got from the link
In the parent:
parentVar = "set by parent";
vRv = window.showModalDialog("modalWindow.html",window.self, "");
In the modal:
dialogArguments.parentVar = "set by modal";
PS: Dont forget to set reference to opener with "window.self"
When i use Shadowbox i can access this.
self.parent.location.reload();
Perhaps this works for you also.
if you look at https://developer.mozilla/En/DOM/Window.openDialog you'll see that you can make the dialog box modal by passing the modal argument through, that way it wont return until the dialog is finished, at that time you can reload parent page.
a modal dialog box is a blocking function. the caller waits until the box is closed, then resumes. Therefore, it is a simple matter of doing the refresh in the script of origin AFTER the call to open the dialog.
For example, let's say you have a page with a grid. You've got an add button to open a modal dialog, and you need the grid to refresh itself (or refresh the page, the problem is the same).
HEre's pseudo code to open modal dialog, then refresh the grid
replace grid.Refresh(); with whatever action you want to happen, it will execute AFTER the dialog box is closed.