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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip