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

176
Visualizações
Is there any way to find out WHO is calling the BOM/javascript API?

When some API is called and I want to know who is calling it.

For example, a web page is navigate to another url somehow, I want to find out why. There must be a function called the location.href=xxx API, but I don't know which is the function. (There are too many function used the location.href so I cannot find it by searching the code.)

My idea is to proxy/intercept the location.href API and add a debugger in it. Just like this: Breaking JavaScript execution when cookie is set.

function debugAccess(obj, prop, debugGet){
    var origValue = obj[prop];
    Object.defineProperty(obj, prop, {
        get: function () {
            if ( debugGet )
                debugger;
            return origValue;
        },
        set: function(val) {
            debugger;
            return origValue = val;
        }
    });
};
debugAccess(document, 'cookie');

But the code is not working for window.location.This API is not configurable, so we cannot use defineProperty to proxy it.

> Object.getOwnPropertyDescriptor(window.location, "href")
< {enumerable: true, configurable: false, get: ƒ, set: ƒ}

Is there other way to do this?

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