javascriptmobileads

How to hide ads on small screens


I wish to hide one ad on mobile version of my site. I want to do it this way.

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

my ad script is also js script but it is not on my domain so I can not use ajax call to call it. Any help is appreciated. my ad code looks like

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

Solution

  • Why don't you just do that with css and media queries?

    Wrap that add in a DIV (let's say <div id="ad_1">...[link to your ad or content]...</div>) and add to your stylesheet

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