Window close() Method - Open "java2s.com" in a new window, and use close() to close the window: - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window close

Description

Window close() Method - Open "java2s.com" in a new window, and use close() to close the window:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="openWin()">Open java2s.com in a new window</button>
<button onclick="closeWin()">Close the new window (java2s.com)</button>

<script>
var myWindow;//w  ww . j a va2s .  c o m

function openWin() {
    myWindow = window.open("http://www.java2s.com", "_blank", "width=500, height=500");
}

function closeWin() {
    myWindow.close();
}
</script>

</body>
</html>

Related Tutorials