Difference between "document.baseURI", "window.location.hostname", and "document.documentURI"? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Difference between "document.baseURI", "window.location.hostname", and "document.documentURI"?

www.w3schools.com/js/js_window_location.asp The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page The window.location object can be written without the window prefix window.location.hostname returns the domain name of the web host The window.location.hostname property returns the name of the internet host (of the current page) document.baseURI Returns the absolute base URI of the document document.documentURI Returns the URI of the document

2nd Oct 2023, 8:40 PM
Katz321Juno
Katz321Juno - avatar
3 Respostas
+ 4
šŸ”¹ window.location is a JavaScript object that tells you where you are on a webpage and can be used to take you to another webpage. For example, if you want to redirect the user to another page, you can use window.location.href = "https://www.example.com";. šŸ”¹ window.location.hostname tells you the name of the website you are on. For example, if you are on the website ā€œhttps://www.example.comā€, window.location.hostname would return ā€œwww.example.comā€. šŸ”¹ document.baseURI and document.documentURI tell you where on that website you are. For example, if you are on the page ā€œhttps://www.example.com/about.htmlā€ document.baseURI would return ā€œhttps://www.example.com/ā€ and document.documentURI would return ā€œhttps://www.example.com/about.htmlā€.
4th Oct 2023, 10:29 PM
Moree
Moree - avatar
+ 4
Anytime šŸ˜Š. Yes, perhaps they have a valid reason. In any case, I wish you the best of luck and great success.
5th Oct 2023, 3:29 AM
Moree
Moree - avatar
+ 2
Moree thank you, w3schools didn't explain the differences that well
4th Oct 2023, 11:22 PM
Katz321Juno
Katz321Juno - avatar