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

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