How to replace url for location object in Javascript

Description

replace() method accepts a single argument, the URL to navigate to, but does not make an entry in the history stack. After calling replace(), the user cannot go back to the previous page.

Example


<!DOCTYPE html> 
<html> 
<body> 
<script type="text/javascript"> 
    setTimeout(function () { <!--   w  ww.  j  a  v a2 s  .c o  m-->
        location.replace("http://www.java2s.com/"); 
    }, 1000); 
</script> 
</body> 
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window