There are two windows: window A (parent) and window B (Modal)
Window A contains a datagrid and A button.
When you click the button, the B window (Modal) is displayed ). Add data in window B. After submission, ask window B to close itself, and refresh window A (parent)
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function openSubWin ()
{
Required parameter showmodaldialog(' B .html ', 'newwindow', 'height = 500, width = 400, top = 0, left = 0, toolbar = no, menubar = yes, scrollbars = yes, resizable = yes, location = no, status = no ');
Window. location. reload ();
}
</Script>
Pop-up window B .html. When the child form is closed, the parent page is refreshed.
When we were working on the material system recently, we had to worry about the modal window. We didn't encounter so many things last time. Please remember.
Parent window js method
Copy codeThe Code is as follows:
Function openwin (id ){
Var answer = window. showModalDialog ("demand. do? Method = queryBOM & mdid = "+ id +" & d = "+ escape (new Date (), window. self, "dialogWidth: 700px; dialogHeight: 620px: center: yes ");
If (answer = 1 ){
Window. location. href = "demand. do? Method = selmd & d = "+ escape (new Date (); // go to the processing page
// Window. location. reload (); refresh the parent window
// Winow. location. reload (true );
}
}
Add an escape (new Date () to avoid reading the cache. You can also add
<META HTTP-EQUIV = "pragma" CONTENT = "no-cache">
<META HTTP-EQUIV = "Cache-Control" CONTENT = "no-cache, must-revalidate">
Subwindow js method:
Copy codeThe Code is as follows:
Function reVal (){
Window. returnValue = 1; // answer value in the parent window
Window. close ();
}
After the modal window is opened, the parent window will wait until the child window returns a value. If it is a form submission or button, the reVal () method will be executed.
Returns the answer value. window. returnValue = 1. I tested it and it seems that only the String type can be returned.
It is difficult to use window. opener. location. reload (); In the subwindow. We will not try it for the modal window. window. opern ()
Another problem is: form submission in the modal window will pop up a new window, which is simply added in This can be done. Note: I didn't want to submit it through form at the beginning. I used js window. location. href to jump to different actions for processing and found that
<Base target = "_ self"> does not work. It seems that <base target = "_ self"> only works for form action =, iframe should be used for implementation.