Capture text of a floating window on current Chrome page?

I am using this code to capture the text of the active Chrome window:

document.body.parentNode.outerText (Found here).

It works but captures much more text than I need (i.e., 15,500 letters vs. 600). Is there a way to limit it to a floating window on the current Chrome page?

Hey Ray,

Right-click on the floating window and Inspect it.

See what object it is.

You may be able to refer to it directly.

Better yet – post the page you're working with if you can.

-Chris

1 Like

Thanks, @ccstone. One of our programmers helped me. He explained exactly what you are describing. The resulting code is:

document.getElementsByClassName("k-window-wrapper")[0].outerText;

In my case this returns only the text on the floating window. Very cool! Maybe I can do it myself next time.

1 Like

Absolutely!

Learning this stuff is not super fast, unless you have a background in object-oriented languages – but as you understand more about JavaScript objects, the DOM (Document Object Model), and the tools at your disposal it get's easier.

-Chris