Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!