JQuery / javascript check if the download is finished?

I have a facebook button like on my website:

<div class="fb-like" data-href="https://www.facebook.com/xxx" data-send="false" data-width="300" data-show-faces="true"> </div> 

I want to use jQuery or java script to check if this div is 100% complete loading on the page and then do other things.

I used $(document).ready and .load to check, but not one of them worked (they perform the function even before the div was finished loading). Should this problem have anything to do with the fact that this div contains an iframe from another site? what am i doing wrong here?

UPDATE I just tried this and it didn't work at all:

 $(document).ready(function() { $(".fb-like").load(function (){ alert("Loaded :)"); }); }); 
+4
source share
2 answers

I believe the problem is that you need to check if the iframe is loaded, not the div. I would suggest changing your selector to include a child iframe and checking for a load event for this.

 $('.fb-like iframe').load(function() { console.log('iframe loaded'); }); 
+5
source
 $('.fb-like iframe').on(function() { console.log('iframe loaded'); }); 
+2
source

All Articles