Question

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>
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top