I want to read an external HTML page after JS scripts of this page are executed.
When I read the page as usual it doesn’t includes content that is added by JS script of this page later.
How is this possible?
const xmlHttp = new XMLHttpRequest.XMLHttpRequest()
xmlHttp.open("GET", path)
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4)
if (xmlHttp.status === 200)
callback(JSON.parse(xmlHttp.responseText))
}
xmlHttp.send()
2
Answers
If it actually works to load the page, then you can try this quite error prone and insecure way
You could create an iframe -> load the url in it -> read the iframe’s contents -> then delete it. This could be your JS code:
For example if this would be the content of page.html:
then the console.log would write out this result: