window.location.href = url;example
window.location.href = "https://net-informations.com";
window.location = "https://net-informations.com";
Difference between window.location and location.href
- window.location is an object that holds all the information about the current document location (host, href, port, protocol etc.).
- location.href is shorthand for window.location.href (you call location from global object - window, so this is window.location.href), and this is only a string with the full URL of the current website.
Assigns a new URL to the current window.
Replaces the location of the current window with the new one.
Sets the location of the current window itself.
self.location = "https://net-informations.com";
Sets the location of the topmost window of the current window.
top.location = "https://net-informations.com";
- What is noscript tag?
- Difference between '=', '==' and '===' operators?
- What is Browser Object Model
- How to test a string as a literal and as an object ?
- What is Associative Array? How do we use it?
- What's the Difference Between Class and Prototypal Inheritance?
- Event bubbling and Event Capturing in JavScript?
- What is the difference between .call() and .apply()?
- What is an immediately-invoked function expression?
- What Are RESTful (REpresentational State Transfer)Web Services?
- TypeError: document.getelementbyid(...) is null
- What's the difference between Null and Undefined?