Set URL location for a window in JavaScript

Description

The following code shows how to set URL location for a window.

Example


<!--  w w  w . j av a  2 s .com-->
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
window.location = "http://www.java2s.com";
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Set URL location for a window in JavaScript