replace method in JavaScript
replace method is used in javascript to replace the current document to the new one.
- <html>
-
- <head>
- <script type="text/javascript">
- function replacemydoc()
- {
- window.location.replace("http://www.c-sharpcorner.com")
- }
- </script>
- </head>
-
- <body>
- <input type="button" value="Click Here To Replace the document" onclick="replacemydoc()" />
- </body>
-
- </html>
Output:
When we Click on the Button the c-sharpcorner Website will be open.