dousi8931
dousi8931
2015-06-28 20:23

如何仅在移动设备,平板电脑等上展示Adsense广告(在桌面上隐藏)

I have recently redesigned my website to a responsive design and everything is working great. The only issue is, the current desktop ads are incompatible with the responsive design. I have discovered a method to hide the desktop ads on mobile, but can;t seem to find a way to only show responsive ads on mobile,tablets,etc (anything but desktop) so that I can create new ad positions for these. My current adsense code is in the format

<script async src="//"></script>
<!-- MH Responsive -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxxxxxx"
     data-ad-slot="xxxxxx"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Any help on this matter would be greatly appreciated.

Kindest Regards

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongzhukuai8177 dongzhukuai8177 6年前

    The way I would do it, I would use PHP code. Here is the code:

    (adsbygoogle = window.adsbygoogle || []).push({}); '; } }?>

    Place that script at the top of the page and when you want to show the ad just paste this script:

    点赞 评论 复制链接分享