For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Thursday, January 12, 2017

load images using JavaScript

Another way to load images using JavaScript

When you write code in JavaScriputer system.
Below is the another way to load images from JavaScript code.

<img src="data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="http://www.mysite.com/media/t1.png">
 
function initS() {
    var myimg = document.getElementsByTagName('img');
    for (var i=0; i<myimg.length; i++) {
        if(myimg[i].getAttribute('data-src')) {
            myimg[i].setAttribute('src',myimg[i].getAttribute('data-src'));
        }
    }
}
setTimeout("initS();", 20000);
</script> 



connect On of OFF.
Share:

0 comments:

Post a Comment

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip