今天发现一个谷歌广告的另类调用方法
函数addGoogel(内容、obj) { addScript ('//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'函数(){ var ins=document.createElement (ins) ins。setAttribute(“类”、“adsbygoogle”) ins。setAttribute (“data-ad-client”、“ca-pub - * * * * * *”) ins。setAttribute(“风格”,obj.style) ins。setAttribute (data-ad-slot, obj.slot) content.appendChild (ins) var inlineScript=document.createElement(脚本) inlineScript。type=' text/javascript ' inlineScript。文本=' (adsbygoogle=窗口。adsbygoogle | | []) .push ({});“ document.getElementsByTagName(身体)[0].appendChild (inlineScript) }) }
调用方法
窗口。onload=function () { var=. getelementbyid (ad_line),//横幅 面积=. getelementbyid (ad_area)//矩阵 如果(! isYd()){//不为移动端 如果(线){//横幅 addGoogel(线,{ 风格:”显示:inline-block;宽度:1100 px;高度:160 px”, 槽:“6183651273” }) } 如果(地区){//矩形 addGoogel(区域,{ 风格:”显示:inline-block;宽度:250 px;高度:250 px”, 槽:“1995310048” }) } } } >之前到此这篇关于谷歌广告之另类js调用实现代码的文章就介绍到这了,更多相关js谷歌广告内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
谷歌广告之另类js调用实现代码