2016-03-30 37 views
0
<form onsubmit="window 
    .open('paper.php?start_t=yes&pass_sub_id=<?php echo $qr1;?>', 
      'print_popup', 
      'width=1000,height=800');"> 

它会打开一个新窗口,当我点击提交的新打开的窗口时,它会回到父页面并打开一个url。如何在php中打开一个新窗口后进入父窗口

+0

我会在当前窗口中使用模态窗口,而不是打开新窗口/选项卡。 – jeroen

回答

0

此代码打开一个新窗口和监听事件beforeunload做出一个XMLHttpRequest,并带来新的内容......

<!DOCTYPE html> 
<html> 
<body> 
<p>Click the button to open the new window.</p> 
<button onclick="myFunction()">Try it</button> 
<script> 
    function myFunction() { 
     var newWindow = window.open("popup.htm", "popup", "width=200, height=100"); 
     console.log("LOG 1:"+newWindow.location.href); 
     newWindow.addEventListener("beforeunload",function(event){ 
      loadNew(); 
     }, true); 
    } 
    function loadNew(){ 
     var xhttp = new XMLHttpRequest(); 
     xhttp.onreadystatechange = function() { 
      if (xhttp.readyState == 4 && xhttp.status == 200) { 
       document.getElementsByTagName("html")[0].innerHTML = xhttp.responseText; 
      } 
     }; 
     xhttp.open("GET", "popup.htm", true); 
     xhttp.send(); 
    } 
    </script> 
</body> 
</html> 

我就是这么做的,因为window.location.href="newLocation.html"没有为我工作..

相关问题