Atributo Window location.hostname
- Página anterior host
- Página siguiente href
- Volver a la capa superior Location de Window
Definición y uso
location.hostname
Atributo que devuelve el host del URL (dirección IP o nombre de dominio).
También se puede configurar location.hostname
Atributo, navegue a la misma URL con un nuevo nombre de host.
Vea también:
Ejemplo
Devolver el nombre del host del URL actual:
let hostname = location.hostname;
Sintaxis
Devolver el atributo hostname:
location.hostname
Configurar el atributo hostname:
location.hostname = hostname
Valor del atributo
Valor | Descripción |
---|---|
hostname | El nombre del host del URL. |
Valor devuelto
Tipo | Descripción |
---|---|
Cadena | El host del URL (dirección IP o nombre de dominio). |
Compatibilidad del navegador
Todos los navegadores lo admiten location.hostname
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Soporte | Soporte | Soporte | Soporte | Soporte | Soporte |
- Página anterior host
- Página siguiente href
- Volver a la capa superior Location de Window