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

  • SEARCH
  • Home
  • 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 9022545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:32:15+00:00 2026-06-16T05:32:15+00:00

Hi I wonder if anyone can help, I’m trying to create a responsive site

  • 0

Hi I wonder if anyone can help, I’m trying to create a responsive site using jQuery (got to do it this way as the target audience is on IE7/8 and css3-mediaqueries.js seems to interfere with jQuery UI that i’m using also). I’m using the following script to detect width and height and apply styles accordingly, it works great for the width but not the height, it loads the SMstyle.css then overwrites with the style.css. I’m trying to learn JavaScript but not super strong at the moment, i know there’s got to an easier way! Any help would be appreciated…

function adjustStyle(width) {
        width = parseInt(width);
        if ((width >= 701) && (width < 1200
        )) {
            $("#size-stylesheet").attr("href", "css/SMstyle.css");
        } else {
            $("#size-stylesheet").attr("href", "css/style.css");
        }
    }

    $(function() {
        adjustStyle($(this).width());
        $(window).resize(function() {
            adjustStyle($(this).width());
        });
    });

    function adjustStyle(height) {
        height = parseInt(height);
        if (height < 800
        ) {
            $("#size-stylesheet").attr("href", "css/SMstyle.css");
        } else {
            $("#size-stylesheet").attr("href", "css/style.css");
        }
    }

    $(function() {
        adjustStyle($(this).height());
        $(window).resize(function() {
            adjustStyle($(this).height());
        });

    });
  • 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-16T05:32:16+00:00Added an answer on June 16, 2026 at 5:32 am

    When dealing with responsive layouts, you don’t really care about the height. The whole concept is that if the content can’t fit with the width, it collapses (and thus increases the height).

    EDIT:

    I believe you need to use $(document) instead of $(this), since the scope of $(this) will be different when you trigger it manually and when it’s triggered by a resize event.

    function adjustStyle() {
        var width = $(document).width();
        var height = $(document).height();
        if (((width >= 701) && (width < 1200)) || (height < 800)) {
            $("#size-stylesheet").attr("href", "css/SMstyle.css");
        } else {
            $("#size-stylesheet").attr("href", "css/style.css");
        }
    }
    
    adjustStyle();
    $(window).resize(function() {
        adjustStyle();
    });
    

    To see the different scopes, try this:

    $(function() {
        console.log('Scope', $(this)); // Scope is DOM-element
        $(window).resize(function() {
            console.log('Scope', $(this)); // Scope is Window object.
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if anyone can help me filter this data in some way? Here
I wonder is anyone can help me with this annoying problem. Trying to insert
I wonder if anyone can help - I have this error showing recently when
I wonder if anyone can help with a jQuery problem I am having. I
I'm a newbie programmer working with jQuery and wonder if anyone can help me
Wonder if anyone can help, I'm looking for a way to take an image
wonder if anyone can help - I thought I had solved this but i
I wonder if anyone can help with the following. using (FbConnection conn = new
I wonder if anyone can help me. I'm using PodHawk - a basic podcast
I wonder if anyone can work this HTML, CSS, Javascript puzzle out? I'm using

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.