How to load a banner ads after page fully load

1.9k views Asked by At

I want to make sure that an affiliate banner ad only loads after all the images are loaded. The banner is just a script tag:

<SCRIPT type="text/javascript" src="cjbannerlink"> </SCRIPT>

I've read a few threads and here's one of the codes that I've tested fiddle:

$(window).bind("load", function() {

    var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "cjbannerlink";
    // Use any selector
    $(".1").append(s);
});

Nothing seems to happen. The banner doesn't appear in the div. Would anyone please tell me if it's possible to fire the banner script last?

1

There are 1 answers

5
Nicolae Olariu On

Try $(document).ready(function() { // code here }); instead:

 $(document).ready(function() {
    console.log('LOADED');
    var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "http://www.qksz.net/1e-itvi";
    // Use any selector
    $(".1").append(s);
});

Click me.