Seeking advice from the knowledgeable community at Stack Overflow! I have a project that I'm unsure how to start, and I could use some fresh ideas.
My goal is to access the HTML source code of a previously opened tab or one that is still loading on my webpage. My initial approach was to obtain the URL of the desired page, send it to the server for processing, and then incorporate it into my website. However, I've encountered issues with the "same domain policy" on the server side. Although JSONP is an option, my situation requires the use of POST requests for other reasons. Thus, I believe that if the target tab or page has been opened and remains active, there must be alternative methods to retrieve its HTML content when my webpage is accessed.
The scenario I envision is as follows: suppose a user opens Page1 in one tab, and subsequently loads mywebpage.html on the same Window. Upon detecting that Page1 is open, mywebpage.html should capture its HTML source code for utilization.
Your insights are appreciated!
Edit:
Let me provide further context for clarity.
I am developing a Firefox plugin featuring a button (myPluginButton) on the toolbar.
When a user clicks myPluginButton, the HTML code of the current webpage is transmitted to the server. The server then processes this data to generate a report, followed by opening a new tab to display said report.
Currently, my method involves extracting the HTML code of the present page using newTabBrowser.contentDocument, transmitting it to the server, and conducting parsing operations remotely. However, this results in unnecessary data traffic. Ideally, only the URL of the current page would be sent to the server, enabling remote retrieval and parsing of the HTML content. Nevertheless, the strict enforcement of the same domain policy poses challenges.
Therefore, my query revolves around the feasibility of implementing a process where clicking myPluginButton initiates the opening of a new tab, which then scans all existing tabs within the browser to retrieve their HTML contents for report generation. As these tabs are actively loading and presumably storing HTML data, such an approach may prove effective.
Your assistance is invaluable. Thank you.