Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. var images = $('img'); // Get all images. (you'll want to modify the selector
  2. // to work with only the desired images)
  3.  
  4. images.load(function() { // Add a load event hander that removes
  5. images = images.not(this); // each image from images once loaded.
  6. });
  7.  
  8. setTimeout(function(){ // After 10 seconds, iterate over each remaining
  9. images.each(function() { // image, reloading each one
  10. // reload this image
  11. });
  12. },10000); // run after 10 seconds
  13.  
  14.  
  15. ================
  16. $('img').error(function(){
  17. var src= $(this).attr('src');
  18. if (window.console) {
  19. console.log('reload image '+ src);
  20. }
  21. var i= src.indexOf("&random=");
  22. if(i > -1) {
  23. src= src.substring(0,i);
  24. }
  25. i = src.indexOf("?random=");
  26. if(i > -1) {
  27. src= src.substring(0,i);
  28. }
  29. if(src.indexOf('?') > -1 ) {
  30. src= src+"&random="+ (new Date().getTime());
  31. } else {
  32. src= src+"?random="+ (new Date().getTime());
  33. }
  34. $(this).attr('src', src);
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement