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

266
Vistas
Call function without actually executing it

So I have such a weird question and I don't know if this is possible, but I will give it a shot anyways.

We have implemented OneTrust, which is a third-party cookie consent vendor and it works great and all, but we have one small hiccup that we are trying to resolve.

So within the below function:

  toggleVideo: function (videoWrapper, src, cover, type, element) {
    var videoElement = video.buildVideo(src, type);

    // We build out video-player element
    videoWrapper.html(videoElement);

    // We define our variables
    let onetrust = window.OneTrust;
    let onetrust_obj = window.ONETRUST_MODULE;
    let target = videoWrapper.html(videoElement).children('iframe');

    console.log(onetrust.Close());

    // Now we wait and observe for a src attribute and then show the video.
    onetrust_obj.src_observer(target, function() {
      video.toggle_show(videoWrapper, cover);
    });
  },

We have an <iframe> element that when clicked play, will wait for consent to execute - The problem is that it needs to "refresh" OneTrust so that it can change the data-src to src attribute (This is all handled using OneTrust JS, so I have no control).

  1. When I add in the console.log(onetrust.Close());, it works just as intended and resumes playing the video when consent is given, the downfall is that it outputs an error in the console. If I remove it, the videos will not play after consent is given.
  2. I don't want to actually execute the onetrust.Close() method as it will close the banner.
  3. OneTrust doesn't have a proper way to "Refresh" their initialization, the techs told me that this was a one-off case, where they don't even know how to handle it.

My questions:

  1. Is there a way that I can properly call onetrust.Close() (Seems to be the only call that actually engages the video to play after) without actually executing it?
  2. If not, is there a way that I can somehow similarly log it, but not actually log it in the console?

Thanks all!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Strange one, may be a race-condition issue so making your code run in the next procedural iteration may resolve the issue - this can be done by adding a setTimeout with no timer value.

setTimeout(() => {
  onetrust_obj.src_observer(target, function() {
    video.toggle_show(videoWrapper, cover);
  });
});

Alternatively, it may be worth digging into the onetrust.Close() method to see if there are any public utilities that may help 'refresh' the context you are working in.

Another idea would be to see what happens after if you ran the onetrust_obj.src_observer code block again.

EDIT: I would like to be clear that I'm just trying to help resolve debugging this, without seeing a working environment it's difficult to offer suggestions 😄

about 4 years ago · Juan Pablo Isaza Denunciar
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