【问题标题】:Disable google AdSense on Mobile Devices using JavaScript使用 JavaScript 在移动设备上禁用 google AdSense
【发布时间】:2017-02-18 21:38:04
【问题描述】:

我想在移动设备中禁用 Google ADS。

现在我有这个

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
}else
{
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="*****"
     data-ad-slot="****"
     data-ad-format="***"></ins>
}
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

但它不起作用。

我很难找到在移动设备中禁用 Google ADS 的代码。

任何帮助或其他想法将不胜感激。

【问题讨论】:

    标签: javascript jquery html adsense


    【解决方案1】:

    您的代码应该可以通过一些语法更改来工作,

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
    isMobile = false;
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
     isMobile = true;
    }
    if(isMobile){
      $(".adsbygoogle").hide();
    }else{
    $(".adsbygoogle").show();
    }
    </script>
    
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    

    你的html,

        <ins class="adsbygoogle"
             style="display:block"
             data-ad-client="*****"
             data-ad-slot="****"
             data-ad-format="***"></ins>
    

    试一试,应该可以的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-24
      • 1970-01-01
      相关资源
      最近更新 更多