Cómo obtener el título de la página HTML con JavaScript?
¿Cómo puedo obtener el título de una página HTML con JavaScript?
154
Author: Michał Perłakowski, 2009-06-29
3 answers
Use document.title
:
console.log(document.title)
<title>Title test</title>
252
Author: ZA.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-11 21:52:45
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-11 21:52:45
Coloque en la barra de URL y luego haga clic en enter:
javascript:alert(document.title);
Puede seleccionar y copiar el texto de la alerta dependiendo del sitio web y del navegador web que esté utilizando.
11
Author: No Mercy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-04 22:50:26
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-04 22:50:26
Puede usar getElementsByTagName
var x = document.getElementsByTagName("title")[0];
alert(x.innerHTML)
1
Author: Vikram S,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-25 09:04:33
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-25 09:04:33