Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:54:35+00:00 2026-06-07T10:54:35+00:00

A website I am working on uses media queries in the CSS to adjust

  • 0

A website I am working on uses media queries in the CSS to adjust the layout based on screen size.

This website is utilizing Google Ads, to help monetize.

If I am correct there isn’t a responsive ad unit offered by Google AdSense I can use.

My idea was to create two include files (google-300×250.html and google-320×50.html) and include one or the other based on the current screen resolution.

Has anyone else tried implementing something similar? What technologies did you use to get this working?

If I beat someone to a solution I will edit my question/post to include my solution.

Thank you all in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:54:37+00:00Added an answer on June 7, 2026 at 10:54 am

    This will grab the HTML from the specified file and load it into a container:

    $(window).on('load', function () {
        if ($(this).width() > 320) {
            $('#my-container').load('google-320x50.html');
        } else {
            $('#my-container').load('google-300x250.html');
        }
    });
    

    This is if you are using an iframe to show the external pages. All you need to do is update the source of the iframe:

    $(window).on('load', function () {
        if ($(this).width() > 320) {
            $('#my-iframe').attr('src', 'google-320x50.html');
        } else {
            $('#my-iframe').attr('src', 'google-300x250.html');
        }
    });
    

    These chunks of code are using 320px as the break-point for showing one version or another. Also, if you want to support window resizes as well you can change the code to run on the window.resize event rather than the window.load event, but you should throttle it so it doesn’t run too often.

    For example:

    var timer   = null;
    $(window).on('load', function () {
        clearTimeout(timer);
        timer = setTimeout(function () {
            if ($(this).width() > 320) {
                $('#my-container').load('google-320x50.html');
            } else {
                $('#my-container').load('google-300x250.html');
            }
        }, 100);
    });
    

    This will only run once the resize event has finished (or paused for 100ms), meaning you won’t create a ton of AJAX requests in the process. You could also setup a flag so you don’t run multiple requests at once, the flag can be resolved in the callback function for the .load() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an eCommerce website for a small merchant. This merchant uses Opera
I'm working on a website for work that uses one master layout for the
I'm working on a website that uses IIS 7's URL rewriting feature to do
I am working on a website that uses a remote websites database to check
So I'm working on a website that uses both jQuery and prototype.js, however their
I have a working website, where I use this expression everywhere. price.ToString(C) It currently
I am working on an ASP.NET website which uses forms authentication with a custom
I am working on an online education website that frequently uses pop up windows.
We are a team of many developers working on a website that uses both
Im working for a company who's website uses javascript to get facebook and twitter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.