>  기사  >  백엔드 개발  >  javascript - 百度广告如何触发执行?

javascript - 百度广告如何触发执行?

WBOY
WBOY원래의
2016-06-06 20:14:561339검색

我想根据滚动条滚动来加载百度广告,
但是百度的广告在文档载入完成后调用就会出问题。
有没有人做过类似的,有没有解决方法?
正常的百度广告代码:

<code>(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div id="' + s + '"></div>');
    (window.slotbydup=window.slotbydup || []).push({
        id: '1232323',
        container: s,
        size: '728,90',
        display: 'inlay-fix'
    });
})();
</code>

然而我想

<code>$(function(){
        function test()
        {
           var s = "_" + Math.random().toString(36).slice(2);
            document.write('<div id="' + s + '"></div>');
            (window.slotbydup=window.slotbydup || []).push({
                id: '1232323',
                container: s,
                size: '728,90',
                display: 'inlay-fix'
            });
        }
        test();//某个操作会调用test
});
</code>

这样子调用就行,有没有办法解决的

回复内容:

我想根据滚动条滚动来加载百度广告,
但是百度的广告在文档载入完成后调用就会出问题。
有没有人做过类似的,有没有解决方法?
正常的百度广告代码:

<code>(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div id="' + s + '"></div>');
    (window.slotbydup=window.slotbydup || []).push({
        id: '1232323',
        container: s,
        size: '728,90',
        display: 'inlay-fix'
    });
})();
</code>

然而我想

<code>$(function(){
        function test()
        {
           var s = "_" + Math.random().toString(36).slice(2);
            document.write('<div id="' + s + '"></div>');
            (window.slotbydup=window.slotbydup || []).push({
                id: '1232323',
                container: s,
                size: '728,90',
                display: 'inlay-fix'
            });
        }
        test();//某个操作会调用test
});
</code>

这样子调用就行,有没有办法解决的

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.