2017-02-18 15 views
0

モバイルデバイスでGoogle ADSを無効にしたいと考えています。私はこのJavaScriptを使用して携帯端末でGoogle AdSenseを無効にする

<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を無効にするコードを見つけようとしています。

何か助けや他のアイデアをいただければ幸いです。

答えて

0

あなたのコードは、いくつかの構文の変更で動作するはず、

<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> 

はそれを試してみる、これは動作するはずです。

関連する問題