Añadir botón de enlace a cuenta regresiva en WordPress

  • Autor Autor AlexxxBcN
  • Fecha de inicio Fecha de inicio
A

AlexxxBcN

Gamma
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Hola tengo este Script funcional en blogger , lo quiero hacer funcionar en WP , todo funciona , menos que muestre el botón link , tengo otro script que al acabar el tiempo se abre el link , pero lo que quiero es que muestre un botón , y tener que cliquear .

PD: Si alguien lo testea en su WP y me comenta si le funciona

Este sería el link que iría en una entrada




la parte que no funciona sería esta: ( Alguna idea o ayuda de el porque esta parte no interactua )
Lo que no funciona:

Insertar CODE, HTML o PHP:
   if (seconds == 0) {
      temp = document.getElementById('countdown');

      var linkGo = document.getElementById("reload").innerHTML;

      $('#Contenedort1').text('Link listo!');

      $('.Contador').find('#Contenedort1').after('<button class="Boton-Ir"><a href="'+linkGo+'">Link</a></button>');
    }


Creo una página en WP y añado todo esto
SCRIPT COMPLETO

Insertar CODE, HTML o PHP:
<div class="Contador">
<div style="text-align: right;" trbidi="on"></div>
<div style="text-align: center;" trbidi="on"></div>
<div id="Contenedort1">
<div style="text-align: center;">Wait a few seconds <span id="countdown"> 10 </span> <i class="fa fa-spinner fa-spin" style="font-size: 45px;"></i> <a id="reload" href="#"></a></div>
</div>
<style type="text/css">
a#reload {display: none;}
#Contenedort1{    background: #344275;
    padding: 14px;
    font-size: 35px;
    font-family: arial;
    color: white;
    font-weight: bold;}

#button.Boton-Ir a {
    color: #000;
    font-size: 20px;
    display: block;
}
#button.Boton-Ir {
    width: 100px;
    padding: 4px;
    height: 50px;
    font-size: 15px;
    color: #000;
    margin: 9px auto;
    position: relative;
}
</style>


<script type="text/javascript">
  var seconds;
  var temp;
function removem1() {
    var xkl = getQueryVariable("url");
    var nkl=xkl.replace("&m=1", "");
document.getElementById("reload").innerHTML=nkl;
}
removem1();
document.getElementById('reload').href=window.location.href;
function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("?&&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=_");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}

  function countdown() {
    seconds = document.getElementById('countdown').innerHTML;
    seconds = parseInt(seconds, 10);

    if (seconds == 0) {
      temp = document.getElementById('countdown');

      var linkGo = document.getElementById("reload").innerHTML;

      $('#Contenedort1').text('Link listo!');

      $('.Contador').find('#Contenedort1').after('<button class="Boton-Ir"><a href="'+linkGo+'">Link</a></button>');
    }
    seconds--;
    temp = document.getElementById('countdown');
    temp.innerHTML = seconds;
    timeoutMyOswego = setTimeout(countdown, 1000);
  }
setTimeout(function(){ countdown(); }, 1000);

</script></div>

<script type="text/javascript">
//add Font Awesome
      var cb = function() {
        var l = document.createElement('link'); l.rel = 'stylesheet';
        l.href = '//maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css';
        var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h);
      };
      var raf = requestAnimationFrame || mozRequestAnimationFrame ||
          webkitRequestAnimationFrame || msRequestAnimationFrame;
      if (raf) raf(cb);
      else window.addEventListener('load', cb);
</script>
 
Última edición:
Gracias , veo que en el test si funciona , pero a mi por alguna razón no , en la consola me sale este mensaje en rojo:
Aunque este error no se si es el motivo de que no me funcione

TypeError: $ is not a function
countdown
Normalmente ese error se produce por que no tienes agregada la librería de jquery, revisa que la tengas.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
 
Gracias , pues si , ese era uno de los errores que tenia , añadí el jquery y listo , luego me surgió otro problema , el plugin Broken Link Checker no me daba bien el link final , desactivé ese plugin y funciona perfecto
 
Atrás
Arriba