Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
JS to update URLs on click breaks Elementor Popups

I am currently using the following code in order to automatically prepend affiliate URLs with my affiliate ID:

`add_action('wp_footer', 'auto_affiliate_url');
function auto_affiliate_url()
{ 
?>

<script>
jQuery(document).ready(function ($) {

      // adairs affiliate URL for redirect
      var adairsaffURL = "https://t.example.com/12345/t/54321?Url=";
      // bedthreads affiliate URL for redirect
      var bedthreadsaffURL = "https://t.example.com/12121/t/21212?Url=";

      // function called when link is clicked
      addAffiliate = function(link) {
        var redirectUrl = link.href;
        if (redirectUrl.indexOf('adairs.com.au') > 0) {
          redirectUrl = adairsaffURL + escape(redirectUrl);
        } else if (redirectUrl.indexOf('bedthreads.com.au') > 0) {
          redirectUrl = bedthreadsaffURL + escape(redirectUrl);
        }
        link.href = redirectUrl;
        return true;
      }

      $("a").click(function(event) {
        addAffiliate(this);
      });


    });
</script>

<?php
}`

This works well, however it creates an issue when attempting to open pop ups in Elementor, as it appends something like this to the URL without opening the pop-up:

#elementor-action%3Aaction%3Dpopup%3Aopen%26settings%3DeyJpZCI6IjM3NjgiLCJ0b2dnbGUiOmZhbHNlfQ%3D%3D

Elementor includes these event triggers, but I am not sure if they are useful in this case.

I would like this code to run only if the click is not for a pop up or internal link. I have tried using if ((link.href).indexOf(location.host) < 0 before the function with no luck. Any help would be much appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda