I am getting content of a webpage (same domain) with javascript. The problem is, that webpage has javascript which do some calculations and then write the result in a div element.
When I retrieve the result, I get the empty div element, because the javascript of the target page still hasn't fully executed.
I need to load the webpage, wait some seconds, and then get the html.
How do I achieve this?
You could use something like this
a. $(document).ready(function() {
// executes when HTML-Document is loaded and DOM is ready
alert("document is ready");
});
b. $(window).load(function() {
// executes when complete page is fully loaded, including all frames, objects and images
alert("window is loaded");
// You can initiate the copy of your Div elements from here.
});
You would require option B, as this is the one which will be fired after your entire page is painted with all the content including the images.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.