Chrome doesn't display content of new popup window until every process is completed

StackOverflow https://stackoverflow.com/questions/19864789

  •  29-07-2022
  •  | 
  •  

Pregunta

From a main window I try to open a popup with javascript, do some work and close the popup. Only in chrome this popup is empty until all work is done, so it doesn't display anything and it is closed. If I don't close it I can see that it takes a while to load and then displays the content. In IE and Firefox the content is display right away. Does anyone know if there is a fix or workaround for this?

Here is my code:

<html>
    <body>
        <script>
            function launch() {
                var pop = window.open ("http://google.com", "pop", "width=300,height=150");
                for (i = 0; i < 1000000000; i++) {
                    var a = i; //Do anything just to make it stay for a while
                }
                pop.close();
            }
        </script>
        <input onclick="launch();" type="button" value="Hello world!">
    </body>
</html>
¿Fue útil?

Solución

You can try this :

function func1() {
  var p=window.open ("http://google.com", "pop", "width=300,height=150");
  setTimeout (function(){p.close()},5000);
 }

The window will be visible for 5 seconds.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top