How to get URL location for a window in Javascript

Description

Passing in a URL to window.location property 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 type="text/javascript"> 
              window.location = "http://www.java2s.com"; 
        </script> 
    </body> 
</html><!--from   w w  w . j a v a 2 s.  co  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