google广告之另类js调用实现代码
作者:mdxy-dxy 时间:2024-05-11 09:44:21
今天发现一个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'
})
}
}
}
标签:js,google广告
0
投稿
猜你喜欢
python 利用turtle库绘制笑脸和哭脸的例子
2022-01-16 08:35:30
详解javascript中的变量提升和函数提升
2024-06-07 15:53:28
ElementUI日期选择器时间选择范围限制的实现
2024-04-09 11:00:28
Windows下Eclipse+PyDev配置Python+PyQt4开发环境
2021-01-26 20:13:42
Golang中的time.Duration类型用法说明
2024-05-02 16:24:12
使用classList来实现两个按钮样式的切换方法
2024-04-16 09:35:19
Python中文分词实现方法(安装pymmseg)
2023-12-06 02:43:41
设计之外随谈
2009-06-16 14:38:00
使用pd.merge表连接出现多余行的问题解决
2023-08-25 11:34:24
python 实现 redis 数据库的操作
2024-01-16 07:46:08
Python 从attribute到property详解
2022-03-15 18:52:40
解决pytorch 保存模型遇到的问题
2021-12-13 08:26:37
python聊天程序实例代码分享
2021-07-09 13:03:33
Java基于redis和mysql实现简单的秒杀(附demo)
2024-01-16 16:55:13
vue 使用vant插件做tabs切换和无限加载功能的实现
2024-04-10 13:49:34
谈一谈基于python的面向对象编程基础
2021-09-09 11:04:39
Oracle 忘记密码的找回方法
2009-03-06 11:12:00
Python数据分析之Python和Selenium爬取BOSS直聘岗位
2021-04-27 08:53:19
Discuz7 的提示效果如何实现
2010-01-13 13:10:00
ThinkPHP 3.2 版本升级了哪些内容
2023-09-05 04:22:04