I want to know if the load event in js will wait until the background-image: url() in css is loaded completely.
What is the exact behaviour in this scenario?
I want to know if the load event in js will wait until the background-image: url() in css is loaded completely.
What is the exact behaviour in this scenario?
$('<img/>').attr('src', 'http://picture.de/image.png').on('load', function() {
$(this).remove(); // prevent memory leaks as @benweet suggested
$('body').css('background-image', 'url(http://picture.de/image.png)');
});
try this
for more reference:-
In your case, you should be sure that the page is 100% loaded.
For a simple and fast result, use jQuery:
$(window).on("load", function() {
// Take the screenshot here.
});
Here is a demo: https://codepen.io/anon/pen/aXgdJq