2013-04-10 287 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>