location.replace()

In this chapter you will learn:

  1. How to replace url for location object

Replace url

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.

<!DOCTYPE html> <!--from  java  2  s . c o m-->
<html> 
<body> 
<script type="text/javascript"> 
    setTimeout(function () { 
        location.replace("http://www.java2s.com/"); 
    }, 1000); 
</script> 
</body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to use search property in Location object
Home » Javascript Tutorial » Location
Location
assign method
Location.hash
Location.hostname
Location.href
location.pathname
location.port
location.reload
location.replace()
Location.search