2013-04-10 272 views
0

我有按鈕,將打開一個彈出窗口,彈出窗口重定向到幾個頁面,並返回到最後一個頁面,返回結果

現在我想獲得在母打開的窗口

最後一頁的狀態

我試圖this

<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title></title> 
    </head> 
    <body> 
     <?php 
     // put your code here 
     ?> 
     <button id="imageinstagram">Images</button> 
     <script src="jquery-1.7.2.min.js" type="text/javascript"></script> 
     <script> 
      $(document).ready(function(){ 
       $('#imageinstagram').click(function(){ 
        window.open("./login.php",'','menubar=no,status=no,width=200,height=200') ; 
       }); 

      }); 
      function HandlePopupResult(result) { 
       alert("result of popup is: " + result); 
      } 
     </script> 
    </body> 
</html> 

現在的login.php重定向到success.php

success.php有以下代碼

<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title></title> 
    </head> 
    <body>   
      <script> 
      function CloseMySelf(sender) { 
       try { 
        window.opener.HandlePopupResult(sender.getAttribute("result")); 
       } 
       catch (err) {} 
       window.close(); 
       return false; 
      } 

      CloseMySelf(); 
     </script> 

    </body> 
</html> 

仍然是我的父窗口沒有理解代碼:(

在子窗口中的javascript愚蠢的錯誤得到任何警告

回答

0

我已經做了愚蠢的錯誤。

<script> 
      function CloseMySelf() { 
       try { 
        window.opener.HandlePopupResult('false'); 
       } 
       catch (err) {} 
       window.close(); 
       return false; 
      } 

      CloseMySelf(); 
     </script>