使用js 调用 google ads
2010-01-30 23:25
274 查看
在网页中插入 Google AdSense 广告,一般将源代码直接嵌入主题模板页面。事实上 Google AdSense 支持并允许使用 JS 文件调用。当然前提是不要因任何原因修改代码,或手动影响广告的定位。这会因违反计划政策而被 Google 咔嚓账号。
芒果以 468x60 的经典广告尺寸代码为例,说明 JS 文件调用的方法。
获得广告单元代码如下:
得到这段代码后,需要将其转化为 JS 形式:
鉴于手工更改比较麻烦,推荐使用在线 HTML 转 JS 工具,例如:http://www.hao123.com/haoserver/jstohtm.htm
将转换后的代码保存为 JS 文件,调用方法如下:
当然,针对强大的 WordPress 程序,可以使用各种 AdSense 广告管理插件来管理代码。此外,该方法不局限于 AdSense,其他广告商同样适用。
芒果以 468x60 的经典广告尺寸代码为例,说明 JS 文件调用的方法。
获得广告单元代码如下:
<script type="text/javascript"><!-- google_ad_client = "发布商 ID"; /* 468x60, 创建于 xx-xx-xx */ google_ad_slot = "xxxxxxxxxx"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
得到这段代码后,需要将其转化为 JS 形式:
document.writeln("<script type=\"text\/javascript\"><!--"); document.writeln("google_ad_client = \"发布商 ID\";"); document.writeln("\/* 468x60, 创建于 xx-xx-xx *\/"); document.writeln("google_ad_slot = \"xxxxxxxxxx\";"); document.writeln("google_ad_width = 468;"); document.writeln("google_ad_height = 60;"); document.writeln("\/\/-->"); document.writeln("<\/script>"); document.writeln("<script type=\"text\/javascript\""); document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">"); document.writeln("<\/script>")
鉴于手工更改比较麻烦,推荐使用在线 HTML 转 JS 工具,例如:http://www.hao123.com/haoserver/jstohtm.htm
将转换后的代码保存为 JS 文件,调用方法如下:
<script language="JavaScript" src="ggad_468x60.js" type="text/javascript"></script>
当然,针对强大的 WordPress 程序,可以使用各种 AdSense 广告管理插件来管理代码。此外,该方法不局限于 AdSense,其他广告商同样适用。
相关文章推荐
- Android端使用WebView注入一段js代码实现js调用android
- 使用reRender局部刷新的时候,自动调用页面加载时候的js
- IE下使用js调用系统activex实现文件下载
- 一个Web页面中调用多个js脚本和梅花雨日历控件的使用
- iOS webView加载本地html 调用 js,css (基本使用)
- Android版使用移动广告平台集成Google Mobile Ads SDK教程
- cocos2d-js如何在android平台上使用js直接调用Java方法
- C#使用技巧之调用JS脚本方法一
- android js互相调用的方法,混淆后js无效,addJavascriptInterface使用注意事项
- 在移动设备中使用js调用陀螺仪api
- google js调用的警告
- 使用JQuery 加载页面时调用JS
- Xilium.CefGlue怎么使用Js调用C#方法
- WebView使用详解(一)——Native与JS相互调用(附JadX反编译)
- 使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码】
- 【第六篇】SAP HANA XS使用JavaScript(JS)调用存储过程(Procedures)
- 使用ExternalInterface调用JS方法-传参数、有返回值!
- Android 使用html做UI的方法---js与java的相互调用
- 1.C#开发winform 开发调运检疫离线制证功能。调用cLodop打印控件(NVelocity模块,生成HTML(包含cLodop打印控件的js),使用WebBrowser,展现网页)总结
- Android WebView的使用方法及与JS 相互调用