Location.hostname
The hostname property can be set with new values that alter the current URL.
Assume starting at http://www.java2s.com/BOOK/HTML-CSS/CatalogHTML-CSS.htm,
location.hostname = "java2s.com";
changes URL to "http://java2s.com/BOOK/HTML-CSS/CatalogHTML-CSS.htm"
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<script>
location.hostname = "java2s.com";
</script>
</body>
</html>