Open Window behind main window

-1

I have this code that it does almost that. The only problem is that I need the user to click on a link so that the main window is in front. I want to open the window automatically after the main window.

This is the code that opens the Window.

<script type="text/javascript">

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



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

This is the code that goes back to the page by clicking on the link.

<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>

CODE LINK RUNNING: link

    
asked by anonymous 30.12.2015 / 18:19

2 answers

1

Unfortunately, what you are planning is not possible. IE allows you to do this, but other browsers (Chrome and Firefox, for example) block such actions without direct action by the user (such as clicking the link).

    
30.12.2015 / 23:14
0

Since you are using jquery ... use jquery-ui , very easy to implement Example jquery-ui docs

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#dialog" ).dialog();
  });
  </script>
</head>
<body>

<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>


</body>
</html>
    
30.12.2015 / 21:07