time to execute script

0

I have a script that I would like to run after a certain time and not when entering the site, it is currently inserted in the text field WordPress Widget I just need to know the way I can do this.

The script is just a code to like Facebook page I want the person to wait for a certain time and the option to enjoy.

    
asked by anonymous 09.01.2017 / 22:23

1 answer

3

I think the ideal for what you are looking for would be to javaScript because the iteration would be more fluid. If it is done in php or wordpress it will probably have to include a module and it would involve a request ajax that should be executed after a certain time that the page loaded, which would cause the same function to make a call on the server. / p>

var time = setInterval(function() { createButton() }, 8000); // Executa a função createButton 8 segundos apos a pagina ter sido renderizada

function createButton() {
  document.body.innerHTML += '<button>Like</button>'; // Insere o elemento
  clearInterval(time); // Limpa a variável para ser executada somente uma vez, e não sair criando botões
}
Aguarde aproximadamente 8 segundos...
    
10.01.2017 / 00:14