Skip to content

Instantly share code, notes, and snippets.

@jonsuh
Created Dec 3, 2012
Embed
What would you like to do?
Responsive Google AdSense Ads
.js-gads {
overflow: hidden;
}
<div class="js-gads">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-XXXXXXXXXXXXXXXX";
if (window.innerWidth <= 350) {
// Small ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 320;
google_ad_height = 50;
} else if (window.innerWidth >= 750) {
// Large ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 728;
google_ad_height = 90;
} else {
// Medium (fallback) ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
}
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-XXXXXXXXXXXXXXXX";
if (window.innerWidth <= 350) {
// Small ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 320;
google_ad_height = 50;
} else if (window.innerWidth >= 750) {
// Large ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 728;
google_ad_height = 90;
} else {
// Medium (fallback) ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
}
//--></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment