They both seem to give me the same thing (the domain name currently executing the script).
So what's the difference (if any) and where should each be used?
They both seem to give me the same thing (the domain name currently executing the script).
So what's the difference (if any) and where should each be used?
MDN Web Docs - window.location
host....
: the host name and port number. [www.google.com]:80
hostname
: the host name (without the port number or square brackets). www.google.com
domain.com
and domain.com
. No square brackets, no port number. Here is the code: console.log(window.location.host); console.log(window.location.hostname);
Jul 1, 2011 at 14:20
host
& origin
is that origin
also has protocol
attached?