My challenge lies in accessing elements in the parent window from a popup, as I keep encountering an error message that reads 'Cannot read property 'document' of null' whenever I attempt to do so.
Despite reading several posts on this issue, none of the solutions provided have worked for me so far.
I've experimented with different approaches:
openerWindow = window.opener.document;
selectedTableRow = openerWindow.querySelectorAll(".highlighted-rows");
And also tried:
selectedTableRow = window.parent.document.querySelectorAll(".highlighted-rows");
Although the code above executes without errors, it returns an empty array even when I know there are table rows with the class .highlighted-rows
.
Additionally, I attempted:
selectedTableRow = window.opener.document.querySelectorAll(".highlighted-rows");
An intriguing observation is that when I run
selectedTableRow = window.opener.document.querySelectorAll(".highlighted-rows");
directly in the Chrome console, it successfully retrieves the desired row. It's only when integrated into the code that it fails to work.