replace method in JavaScript

replace method in JavaScript

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