JS Close modal window Refresh parent page or jump page _javascript tips

Source: Internet
Author: User

There are two windows: a window (parent), b window (modal)

A a window has a DataGrid, a button.

When the button is clicked, the b window (modal) is ejected. Add the data in the b window, request the b window to shut itself down, and then refresh the window A (parent)

Copy Code code as follows:

<script type= "Text/javascript" >
function Opensubwin ()
{
window.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 subform b.html, triggering parent page refresh when the subform is closed

Recently do the material system, but also related to modal window problem, the last time I did not encounter so many things, write it down
Parent Window JS Method
Copy Code code 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 Processing page
Window.location.reload (); Refreshing the parent window
Winow.location.reload (TRUE);

}
}

Add an Escape (new Date ()) to avoid reading the cache, but also in the child window, add
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache, must-revalidate" >
Sub-window JS method:
Copy Code code as follows:

function ReVal () {
window.returnvalue=1; The value of the answer in the parent window
Window.close ();
}

After the modal window is opened, the parent window waits for the child window to return a value, and executes the Reval () method if it is a form submission or a button
Returns the value of answer, window.returnvalue=1 I tested this place. It seems that only string types can be returned, the array type is not good

Use Window.opener.location.reload () in the child window; Does not use, does not try in the modal window, Window.opern ()

There is also a problem: in the modal window, form submission will pop up a new window, the problem is simply in Can be done, note: I just start is not want to submit through form, with JS Window.location.href jump to different action to deal with, found
<base target= "_self" > does not work, it seems that <base target= "_self" > Just for the form action= "" To work, this place should be able to use IFRAME to achieve.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.