使用 html 插入 google 个广告

inserting google advertisements with html

美好的一天,

很抱歉,如果这可能是一个重复的问题,但大多数问题都提到了 Google AdSense,而我从未使用过它。

进入正题,我想知道是否有人知道如何将来自 Google 的广告添加到 HTML 5 站点。

我正在做一个项目。实际的网站文件将在本地驱动器上,但我想在我的页面上插入一个随机 Google 广告并将它们放在这个部分。

我不想制作广告或任何类似的东西。假设我有一个 600px x 100px 块的部分,我希望 "draw" 某个类别的任何广告在 运行 时间放置在那里。

就像我说的那样,页面本身是本地的,但是使用互联网访问页面应该会获取这些广告。

提前感谢您的快速回复,如果解释过度,我深表歉意。

参考Get and copy the ad code(点击"If you haven't yet created an ad unit under "如何获取和复制您的广告代码)
然后参考Where to paste the ad code in your HTML

解释的很好

在 HTML 中插入 Google Adsense 非常容易,只需将您的代码粘贴到 body 标签内,然后使用 bootstrap 或 CSS3定位。

<html>
    <head>
        This is the head of your page
        <title>Example HTML page</title>
    </head>
    <body>
        **Paste your google adsense code inside the body**
        This is the body of your page.
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        <!-- Homepage Leaderboard -->
        <ins class="adsbygoogle"
            style="display:inline-block;width:728px;height:90px"
            data-ad-client="ca-pub-1234567890123456"
            data-ad-slot="1234567890"></ins>
        <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
        </script>
    </body>
</html>
<html>
<head>
This is the head of your page
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.

<!-- Ad block -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- End of Ad block -->

</body>
</html>

无法从本地主机或已保存的 html 文件加载 Adsense。不起作用。 Google 在展示广告之前检查域是否被 adsense 接受。 因此,当您从本地加载广告时,域 属性 将会丢失。