Latest web development tutorials

Location host property

Location Object Reference Location Object

Definition and Usage

host property is a readable and writable string sets or returns the host name and port number of the current URL.

grammar

location.host


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support host properties


Examples

Examples

Returns the host name and port of the current URL:

<script>

document.write(location.host);

</script>

Examples of the above output ::


try it"


Location Object Reference Location Object