通过JS(JavaScript)调用的方式来轻松管理Adsense广告代码

  实在抱歉,今天小程了解到,此方法只适合在网站的目录下来调用,使用其他空间是不允许的。

  Adsense广告代码现在支持JS调用,而通过JS调用的方式则会让你轻松很多,不用再那么费劲了,你只需要管理好调用的JS代码,就可以管理Adsense广告的显示和隐藏了,非常方便。

  而且这种用JS调用的方式完全符合Google的政策,并没有什么违规的行为。不过,要注意的是,不能修改Adsense代码,这样还是算违规的哦。

  下面小程简单举个例子来说明如何将Adsense的广告代码转化为JS代码并调用的。

  例如这样一个Adsense代码:

<script type=”text/javascript”><!–
google_ad_client = “你的Adsense pub号”;
/* 说明 */
google_ad_slot = “xxxxxxxxxx”;
google_ad_width = 468;
google_ad_height = 15;
//–>
</script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>

  我们将其转化为JS代码,这里建议使用网上的转化工具,非常方便,小程这里推荐一个,地址在这里。我们进入以后将代码复制进去,接着底下就会出现生成的JS代码了:

document.writeln(“<script type=\”text/javascript\”><!–“);
document.writeln(“google_ad_client = \”你的Adsense pub号\”;”);
document.writeln(“/* 说明 */”);
document.writeln(“google_ad_slot = \”xxxxxxxxxx\”;”);
document.writeln(“google_ad_width = 468;”);
document.writeln(“google_ad_height = 15;”);
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>”);

  然后我们新建一个记事本,将其保存,并将后缀改为“.JS”就可以了。

  最后我们将文件上传,例如你的文件名是“abc.js”,那么我就用以下的语句来调用即可,例如http://xc84.com/abc.js或者是http://xc84.com/abc/abc.js。

<script language=”JavaScript” src=”/abc.js” type=”text/javascript”></script>

  这样调用的方式会加快一些网站的打开速度,并且如果你不想显示Adsense广告了,只需暂时把js文件删除就行了。

评论

  1. 15 年前
    2009-9-23 18:23:22

    这样,有没有风险呀

    • 免费资源部落
      15 年前
      2009-9-23 20:05:46

      没有,Google官方是认可的,只是有一条,你不能修改调用的Adsense代码。

  2. 15 年前
    2009-9-23 13:23:57

    坐沙发先
    然后收藏
    等我有了广告了再看

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇