首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 开源 FAQ 第二书店 博文视点 程序员
频道: 研发 数据库 中间件 信息化 视频 .NET Java 游戏 移动 服务: 人才 外包 培训
    图书品种:235680
       
热门搜索: ASP.NET Ajax Spring Hibernate Java

22.10  用JavaScript调用Google AdSense

【实例描述】

Google AdSense是Google为网站提供广告的服务。本例学习如何使用JavaScript调用这个广告服务,并在自己的网站中显示这些广告。

【实现代码】

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

    <title>中文搜索</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>

<div>

<script type="text/javascript">

//以下是Google AdSense服务的参数

google_ad_client = "pub-5660892815235048";

google_ad_width = 336;

google_ad_height = 280;

google_ad_format = "336x280_as";

google_ad_type = "text_image";

google_ad_channel = "";

google_color_border = "FFFDF7";

google_color_bg = "FFFDF7";

google_color_link = "0000FF";

google_color_text = "191919";

google_color_url = "7F7F7F";

</script>

<script type="text/javascript"

  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

//此处是服务的js代码

</script>

</div>

</body>

</html>

【运行效果】

调用广告效果如图22-10所示。

图22-10  调用广告效果

【难点剖析】

本例的重点是Google AdSense参数的调用,以及显示广告内容的JavaScript文件“show_ ads.js”。调用方法不能随意,具体解释可参考Google AdSense的官方网页。

查看所有评论(0)条】

最近评论



正在载入评论列表...
热点评论