How to change the href property for Location object in Javascript

href property

Passing in a URL to location.href property starts the process of navigating to the new URL and makes an entry in the browser's history stack.

Example


<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">
           location.href = "http://www.java2s.com"; 
    </script>
</head><!--from w  ww  . ja va 2 s. c o m-->
<body>
</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