Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 24, 2019 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/9bfe9a42553889de8cb7d4439ffe1d8d to your computer and use it in GitHub Desktop.
Save parzibyte/9bfe9a42553889de8cb7d4439ffe1d8d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Ejemplo de cambio de título</title>
<script>
var tituloOriginal = document.title; // Lo guardamos para restablecerlo más tarde
window.onblur = function(){ // Si el usuario se va a otro lado...
document.title = "Hey, vuelve aquí";// Cambiamos el título
}
window.onfocus = function(){
document.title = tituloOriginal; // Si el usuario vuelve restablecemos el título
}
</script>
</head>
<body>
<h1>Si te vas a otra pestaña, el título cambia</h1>
<a href="https://parzibyte.me/blog">parzibyte.me/blog</a>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio nihil facilis natus earum repellat libero saepe, quasi amet cupiditate tenetur molestias error pariatur, quisquam velit odit suscipit quos accusantium et.
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment