replace method in JavaScript

replace method is used in javascript to replace the current document to the new one.
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function replacemydoc()
  5. {
  6. window.location.replace("http://www.c-sharpcorner.com")
  7. }
  8. </script>
  9. </head>
  10. <body>
  11. <input type="button" value="Click Here To Replace the document" onclick="replacemydoc()" />
  12. </body>
  13. </html>
Output:
1.png
When we Click on the Button the c-sharpcorner Website will be open.