Home > Web Front-end > JS Tutorial > Detailed explanation on how JavaScript implements the method of refreshing the parent window data after submitting the modal window.

Detailed explanation on how JavaScript implements the method of refreshing the parent window data after submitting the modal window.

黄舟
Release: 2017-06-18 11:52:07
Original
1062 people have browsed it

This article mainly introducesJavaScriptThe method of refreshing the parent window data after submitting the modal window, involving related operating skills of javascript window interaction, friends in need can refer to the following

The example of this article describes the JavaScript method of refreshing the parent window data after submitting the modal window. Share it with everyone for your reference, the details are as follows:

Sometimes, it is designed according to the needs. In a window, click the button to pop up the modal window. In the modal window, after adding the data (submit), close the modal. window, and refresh the parent window, but the modal window does not support window.opener, so the parent window cannot be obtained, which means that the parent window cannot be obtained after closing the modal window, but you can use showModealDialog The return value is used to determine whether to refresh. When showModealDialog is called, the parent window code will stop at this line. When the pop-up modal window is closed, assign a value to window.returnValue, and then call the window.close() method. , and finally submit. After the data is submitted, the modal window will be closed. At this time, the program returns to the parent window, and showModealDialog gets the return value. Next, based on the return value, you can decide whether to reload. Note: To avoid opening a new window, Be sure to add under the <head> of the parent window, so that you can close the modal window and refresh the parent window.

Code 1: parent form


function showDatas(){
  var re=window.showModalDialog("url","parameter","description");
  if(re==1){
    window.location.reload();
  }
}
Copy after login

Code 2: modal form


function subForm(){
  window.returnValue="1";
  window.close();
  document.getElementById("myForm").submit();
}
Copy after login

The above is the detailed content of Detailed explanation on how JavaScript implements the method of refreshing the parent window data after submitting the modal window.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template