简体   繁体   English

页面完全加载后如何加载横幅广告

[英]How to load a banner ads after page fully load

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. 标语未显示在div中。 Would anyone please tell me if it's possible to fire the banner script last? 有人可以告诉我是否有可能最后触发横幅脚本吗?

Try $(document).ready(function() { // code here }); 尝试$(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. 点击我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM