Home >Web Front-end >JS Tutorial >What is the difference between `window.location.href` and `window.open()` in JavaScript?
Differences Between window.location.href and window.open() Methods in JavaScript
The distinction between window.location.href and window.open() lies in their nature and functionality.
window.location.href
Example:
<code class="javascript">window.location.href = "http://www.example.com"; // Redirects to example.com</code>
window.open()
Example:
<code class="javascript">window.open("http://www.google.com"); // Opens Google in a new window</code>
Additional Features
The above is the detailed content of What is the difference between `window.location.href` and `window.open()` in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!