Some webpages can take a while to load or have specific content you are interested in that may load after the main page has loaded. This is especially true on AJAX heavy web pages were content is loaded via JavaScript.
GrabzIt detects when a webpage loads but for some of the specific circumstances listed above it needs some additional instructions in the form of a delay that should be used before the capture is taken or by waiting for a specified HTML element to appear before the capture should go ahead. These techniques can be used if you are taking screenshots of web pages or converting HTML into PDF’s, images or Word documents, and you have a premium package. However both techniques are limited to a maximum wait time of thirty seconds.
These features are also available in our online screenshot and web scraper tools.
How to wait for a specified time before performing a capture?
Just specify the delay in milliseconds and this is how long the capture will wait for. Remember that there are 1000 milliseconds in a second. All of the below examples wait three seconds before capturing the webpage.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.4.8/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com",
{"delay": 3000}).Create();
</script>
How to wait for a HTML element to appear before performing a capture?
This technique is especially useful on webpages that use AJAX methods to load content. First use your browsers developer tools to identify the element that you need to wait to appear for, take a note of its id, class or make a more complicated CSS selector. Then specify this CSS selector and once the element becomes visible the web page is captured. Note that if there are multiple matching HTML elements it will appear as soon as one is visible.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.4.8/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com",
{"waitfor": "#Content"}).Create();
</script>