I am trying to capture all clicks in the salesforce classic console from a script in a custom console component.

The following javascript logs all onclick events in the console in the frame of that console component, but not of the parent or child frames.

Is it possible and if so, how would I capture events in these other frames?

I have tried parent, window.top, and document to no success. If I ran into an exception I would expect XSS errors in the console, but I do not receive any.

Object.keys(window).forEach(key => {
    if (/^onclick/.test(key)) {
        window.addEventListener(key.slice(2), event => {


I am trying to track the actions and events on the page to track user actions to troubleshoot issues without relying on cascaded information and identify user patterns to optimize UI.

Alternative Solutions in mind:

Include script at each needed level of the DOM and pass captured events to a centralized handler.

Use jQuery to add event listeners to specific elements on the page and on various events and pass captured events to a centralized handler.

The problem I have with the alternative solutions below is I don't believe they would capture actions performed on the console elements, such as changing tabs, clicking in the top search bar, etc.

  • That sounds like it would be a security vulnerability. – Adrian Larson May 23 '19 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.