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

260
Visualizações
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 Respostas
Responde à pergunta

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 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