google廣告之另類js調(diào)用實現(xiàn)代碼
今天發(fā)現(xiàn)一個google廣告的另類調(diào)用方法
function addGoogel (content, obj) { addScript(’//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js’, function () { var ins = document.createElement(’ins’) ins.setAttribute(’class’, ’adsbygoogle’) ins.setAttribute(’data-ad-client’, ’ca-pub-******’) ins.setAttribute(’style’, obj.style) ins.setAttribute(’data-ad-slot’, obj.slot) content.appendChild(ins) var inlineScript = document.createElement(’script’) inlineScript.type = ’text/javascript’ inlineScript.text = ’(adsbygoogle = window.adsbygoogle || []).push({});’ document.getElementsByTagName(’body’)[0].appendChild(inlineScript) })}
調(diào)用方法
window.onload = function () { var line = document.getElementById(’ad_line’), // 橫幅 area = document.getElementById(’ad_area’)// 矩陣 if (!isYd()) { // 不為移動端 if (line) { //橫幅 addGoogel(line, { style: ’display:inline-block;width:1100px;height:160px’, slot: ’6183651273’ }) } if (area) { //矩形 addGoogel(area, { style: ’display:inline-block;width:250px;height:250px’, slot: ’1995310048’ }) } }}
到此這篇關(guān)于google廣告之另類js調(diào)用實現(xiàn)代碼的文章就介紹到這了,更多相關(guān)js google廣告內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. Java實現(xiàn)基于http協(xié)議的網(wǎng)絡(luò)文件下載2. Java 3D的動畫展示(Part1-使用JMF)3. Django nginx配置實現(xiàn)過程詳解4. layui Ajax請求給下拉框賦值的實例5. IntelliJ Idea 2020.1 正式發(fā)布,官方支持中文(必看)6. Python基于jieba, wordcloud庫生成中文詞云7. JavaScript中Object、map、weakmap的區(qū)別分析8. Java實現(xiàn)UDP多線程在線咨詢9. 小技巧處理div內(nèi)容溢出10. Django ORM實現(xiàn)按天獲取數(shù)據(jù)去重求和例子
