Home  >  Article  >  Web Front-end  >  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.

黄舟
黄舟Original
2017-06-18 11:52:07961browse

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 2a6ca4bf612e61b8b04847c881d3bd93 under the 8cea2e99ba256aa9b779f5ab5949ca21 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();
  }
}

Code 2: modal form


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

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!

Statement:
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