如何在小屏幕上隐藏广告

How to hide ads on small screens

我想在我的网站的移动版本上隐藏一个广告。我想这样做。

<script>
    if(screen.width > 900){
        "here call the script that is ad"
    }
</script>

我的广告脚本也是 js 脚本,但它不在我的域中,所以我无法使用 ajax 调用来调用它。任何帮助表示赞赏。 我的广告代码看起来像

<script src='//url..'> </script> 

你为什么不直接用 css 和媒体查询来做呢?

包装 DIV(比方说 <div id="ad_1">...[link to your ad or content]...</div>)并添加到您的样式表

@media only screen and (max-width: 900px) {
  #ad_1 { display: none; }
}