deeejay icon

JS - Open and close a window

deeejay | PRO | 10/07/15 09:23:22 PM UTC | 0 ⭐ | 295 👁️ | Never ⏰ | []
JavaScript |

670 B

|

None

|

0 👍

/

0 👎

Open and close a browser window and refresh parent page using JavaScript
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Page</title>
<script>
function closeOnLoad(myLink)
{
  var newWindow = window.open(myLink, "connectWindow", "width=600,height=400,scrollbars=yes");
  setTimeout(
             function()
             {
                newWindow.close();
        location.reload(); 
             },
            1000
            );
  return false;
}
</script>
</head> 
<body>
  <p><a href="#" onclick="javascript:closeOnLoad('http://www.google.com/');">Click to open popup</a>; it will close automatically after five seconds.</p>
</body>
</html>

Comments