google廣告之另類js調用實現(xiàn)代碼
今天發(fā)現(xiàn)一個google廣告的另類調用方法
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) })}
調用方法
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’ }) } }}
到此這篇關于google廣告之另類js調用實現(xiàn)代碼的文章就介紹到這了,更多相關js google廣告內容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持好吧啦網(wǎng)!
相關文章:
1. jQuery加PHP實現(xiàn)圖片上傳并提交的示例代碼2. Idea 2020.2安裝MyBatis Log Plugin 不可用的解決方法3. IDEA怎么切換Git分支的實現(xiàn)方法4. 解決idea刪除模塊后重新創(chuàng)建顯示該模塊已經(jīng)被注冊的問題5. JSP Tag Library-AjaxTags 1.0, released6. 小區(qū)后臺管理系統(tǒng)項目前端html頁面模板實現(xiàn)示例7. 完美實現(xiàn)浮動元素橫排居中顯示8. Python使用ElementTree美化XML格式的操作9. JSP動態(tài)網(wǎng)頁開發(fā)技術概述10. jsp request.getParameter() 和request.getAttribute()方法區(qū)別詳解
