Window open() Method - Replace the current window with a new window: - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window open

Description

Window open() Method - Replace the current window with a new window:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from   www. j  a  v a  2 s .c  om
    var myWindow = window.open("", "_self");
    myWindow.document.write("<p>I replaced the current window.</p>");
}
</script>

</body>
</html>

Related Tutorials