Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
Blink and change the title of website when user isn't in tab

I want to grab user attencion back to the website when hes in different tab, so i would like to recreate effect from sephora.pl

If you tab out you see an nice alert as title ('What are you waiting for?'), and then back to page title. Effect stops when you are on the page again. I managed to create this parts and i stuck. Any idea how to make it blink?

$(function() {
    // Get page title
    var pageTitle = $("head title").text();

    // Change page title on blur
    $(window).blur(function() {
      $("title").text("Come back to us");
        // Somehow make it blink between Come back to us and pageTitle every 1200ms or so...
    });

    // Change page title back on focus
    $(window).focus(function() {
      $("title").text(pageTitle);
    });
}); 
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You could use plain javascript. Something like this;

let defaultTitle = document.title
window.onblur = () => {
   //change title, blink title, whatever
   document.title = "New title"
}
window.onfocus = () => {
   //back to default title
   document.title = defaultTitle
}

BTW, yeh, I've seen it on Alibaba, so guess it do increase leads.

about 4 years ago · Juan Pablo Isaza Relatório

0

Ok, so after small-talks in commentary section i managed to make it work like this:

const orginalTitle = $(document).prop('title');
function flashText() {
  const newTitle = ('Back to us!');
  if ($(document).prop('title') === orginalTitle) {
    document.title = newTitle;
  } else {
     document.title = orginalTitle;
  }
}

$(function changeTitle() {
    let nIntervId;
    $(window).blur(function() {
    if (!nIntervId) {
    nIntervId = setInterval(flashText, 1100);
    }
    });
    $(window).focus(function() {
      clearInterval(nIntervId);
      nIntervId = null; 
      $("title").text(orginalTitle);
    });
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda