2016-11-11 14 views
0

モーダルウィンドウが閉じているときに親ウィンドウを閉じようとしています。 JQuery UIを使用してカスタムモーダルウィンドウを作成しましたが、親ウィンドウを閉じることができません。ここで モーダルがJQueryで閉じられた後に親ウィンドウを閉じる

$(document).ready(function() {   
     dialog = $("#dialog").dialog({ 
      autoOpen: false, 
      height: 300, 
      width: 500, 
      modal: true, 
      buttons: { 
       "Approve": addUser, 
       Cancel: function() { 
        dialog.dialog("close"); 
       } 
      } 
     }); 

     }); 

function addUser() { 

      var getJSON = function (url) { 
       return new Promise(function (resolve, reject) { 
        var xhr = new XMLHttpRequest(); 
        xhr.open('get', url, true); 
        xhr.withCredentials = true; 
        xhr.onload = function() { 
         var status = xhr.status; 
         if (status == 200) { 
          resolve(xhr.response); 
         } else { 
          reject(status); 
         } 
        }; 
        xhr.send(); 
       }); 
      }; 

      getJSON(url).then(function (data) { 
       var result = "Approved Successfully" 
       dialog.dialog("close");      
       alert(result); 
       window.close(); ///Here, the PARENT Window is not closing 

      }, function (status) { //error detection.... 
       alert('Something went wrong.'); 
      }); 
} 

は、私のモーダルボックスが閉じているが、 はwindow.close()がは親ウィンドウを閉じていません。

メッセージが届いています"スクリプトは、開いたウィンドウのみを閉じることがあります。"

この問題を解決する方法。

おかげ

答えて

0

親ウィンドウ内の関数を作成します

window.parent.close(); 
関連する問題