The assign()
method loads a new document.
assign |
Yes | Yes | Yes | Yes | Yes |
location.assign(URL)
Parameter | Type | Description |
---|---|---|
URL | String | Required. Specifies the URL of the page to navigate to |
No return value
The following code shows how to Load a new document.
<!DOCTYPE html>
<html>
<body>
<!--from w w w . ja va 2s.c o m-->
<button onclick="myFunction()">Load new document</button>
<script>
function myFunction() {
location.assign("http://www.example.com");
}
</script>
</body>
</html>
The code above is rendered as follows: