How to use assign method to location object in Javascript

Assign value to location

Passing in a URL to location.assign() method starts the process of navigating to the new URL and makes an entry in the browser's history stack.

Example


<!DOCTYPE HTML> 
<html> 
    <body> 
        <script> 
             document.location.assign("http://java2s.com"); 
        </script> 
    </body> 
</html><!--from ww  w .  ja  va 2 s . c o m-->

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