Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var images = $('img'); // Get all images. (you'll want to modify the selector
- // to work with only the desired images)
- images.load(function() { // Add a load event hander that removes
- images = images.not(this); // each image from images once loaded.
- });
- setTimeout(function(){ // After 10 seconds, iterate over each remaining
- images.each(function() { // image, reloading each one
- // reload this image
- });
- },10000); // run after 10 seconds
- ================
- $('img').error(function(){
- var src= $(this).attr('src');
- if (window.console) {
- console.log('reload image '+ src);
- }
- var i= src.indexOf("&random=");
- if(i > -1) {
- src= src.substring(0,i);
- }
- i = src.indexOf("?random=");
- if(i > -1) {
- src= src.substring(0,i);
- }
- if(src.indexOf('?') > -1 ) {
- src= src+"&random="+ (new Date().getTime());
- } else {
- src= src+"?random="+ (new Date().getTime());
- }
- $(this).attr('src', src);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement