Guest User

Untitled

a guest
Aug 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. how to check if a same domain, dynamically loaded iframe which i have no control over is 100% loaded?
  2. function callIframe(url, callback) {
  3. $(document.body).append('<IFRAME id="myId" ...>');
  4. $('iframe#myId').attr('src', url);
  5.  
  6. $('iframe#myId').load(function()
  7. {
  8. callback(this);
  9. });
  10. }
  11.  
  12. $(".post_relative").each(function () {
  13. var post_relative = $(this);
  14. var photoset = post_relative.find('.html_photoset');
  15. if(photoset.length){
  16. var myFrame = photoset.find("iframe");
  17. myFrame.load(function(){
  18. var newCover=myFrame.contents().find('.photoset').children(':first-child').children(':first-child').attr("href")+ '?'+(Math.random()*10000);
  19. post_relative.append("<img src='"+ newCover +"' alt='Cover Page' />");
  20. var psHeight = post_relative.find('img');
  21. psHeight.load(function(){
  22. if (psHeight.height()>heightRef){
  23. psHeight.height(heightRef);
  24. }
  25. myFrame.hide();
  26. })
  27. })
  28. }
  29. });
  30.  
  31. $("#iFrameId").load(function (){
  32. // do something once the iframe is loaded
  33. });
Add Comment
Please, Sign In to add comment