google广告之另类js调用实现代码
今天发现一个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调用实现代码的文章就介绍到这了,更多相关js google广告内容请搜索好吧啦网以前的文章或继续浏览下面的相关文章希望大家以后多多支持好吧啦网!
相关文章:
1. 一文读懂Spring Cloud-Hystrix2. PHP终止脚本执行的实例代码3. 详解JavaScript是如何验证URL的4. SQL+HTML+PHP 一个简单论坛网站的综合开发案例(注册、登录、注销、修改信息、留言等)5. Python Pandas pandas.read_sql函数实例用法6. Python Opencv轮廓常用操作代码实例解析7. Python中Selenium模块的使用详解8. Python语言规范之Pylint的详细用法9. 使用python创建生成动态链接库dll的方法10. python用dataframe将csv中的0值数据转化为nan缺失值字样

网公网安备