Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between host and hostname in window [duplicate]

People also ask

Is host and hostname the same?

A hostname is a label assigned to a device (a host) on a network. It distinguishes one device from another on a specific network or over the internet. The hostname for a computer on a home network may be something like new laptop, Guest-Desktop, or FamilyPC.

What is window location host?

The window.location.hostname property returns the name of the internet host (of the current page).

What is location host?

The location. host property returns the host (IP adress or domain) and port of a URL. The location. host property can also be set, to navigate to the same URL with a new host and port.

What does Window location mean?

The location property of a window (i.e. window. location ) is a reference to a Location object; it represents the current URL of the document being displayed in that window. Since window object is at the top of the scope chain, so properties of the window.


As specified by the definition:

  • hostname is the host name (without the port number or square brackets)
  • host is the host name and port number

So depending on your needs, you should use the one or the other. Most of the HTTP communication will go on default port 80, so you might omit it then. On the other hand, if you suspect that you need to take regard to non-standard port settings, you need to include that information in your source code as well.


Say we have this example:

example.org:1111

The hostname is the name - example.org

The host includes both the host name, and any port numbers associated - example.org:1111