I have been facing a challenge trying to extract data from a school portal's Peoplesoft page that contains an iframe element. The issue arises when I navigate within the portal, such as clicking on a button to search for classes, causing changes in the displayed elements without altering the source code (as confirmed by inspect element tool). While I can access elements on the homepage using JavaScript, I struggle to do so after the page reloads and new elements are injected into the iframe. How can I modify my script to access these post-reload elements?
var iframe = document.getElementById("id of iframe");
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var element = innerDoc.getElementById("name of id desired in iframe");