2015-12-30 66 views
-1

我需要在父窗口后面打开一个窗口,而且我没有找到任何要做的事情。 有人可以帮助我使用此代码或提示吗?父窗口后面的打开的窗口JS或PHP

Parent.php

<script type="text/javascript"> 

$(document).ready(function() { 
    window.name = "parent"; 
    $('#link').click(function (event){ 
     event.preventDefault(); 
     window.open('child.php', 'fullscreen=yes', 'scrollbars=auto'); 
    }); 
}); 
</script> 



<body> 
     <a id="link" href="/">Open Window </a> 
</body> 

child.php

<script type="text/javascript">//<![CDATA[ 
    $(document).ready(function() { 

     $('#link').click(function(event){ 
      event.preventDefault(); 
      console.log(window.opener.location); 
      var goBack = window.open('', 'parent'); 
      goBack.focus(); 

    }); 
    });//]]> 

    </script> 


    <body> 

     <a id="link" href="#">Return to Parent </a> 

    </body> 

LINK CODE:http://pontodosjogos.com/testegrana.php

+0

你google了吗? 试试这个问题: http://stackoverflow.com/questions/11407153/open-a-window-behind-the-current-window-using-javascript-jquery –

+0

我尝试使用您发送给我的链接代码不工作。 @KashifUllah – Murilo

+0

我得到了这段代码,只不过它只有在你放置一个返回链接并把函数标识为链接上的点击时才起作用。 我希望她自动回来,而不必点击任何内容。 @KashifUllah – Murilo

回答

1

您可以使用此代码来显示一个弹出式窗口下:

<script> 

//specify page to pop-under 
var popunder="http://yahoo.com"; 

//specify popunder window features 
//set 1 to enable a particular feature, 0 to disable 
var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"; 

function loadpopunder() 
{ 
win2=window.open(popunder,"",winfeatures); 
win2.blur(); 
window.focus(); 
}  

loadpopunder(); 


</script> 

来源: http://www.javascriptkit.com/script/script2/popunder.shtml

请记住,浏览器可能会阻止弹出式窗口,并且从用户的角度看它们通常很烦人,所以尽量不要过度使用这些窗口。