Window close() Method - Open "book2s.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 "book2s.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 book2s.com in a new window</button>
<button onclick="closeWin()">Close the new window (book2s.com)</button>

<script>
var myWindow;//ww w  .ja  v a2s  . co  m

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

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

</body>
</html>

Related Tutorials