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 7727197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:23:59+00:00 2026-06-01T05:23:59+00:00

A current jQuery project of mine requires browser resize (width AND height) functionality, some

  • 0

A current jQuery project of mine requires browser resize (width AND height) functionality, some of the supported resolutions are funky when compared to each other. Any suggestions to improve this comparative statement are welcome. I tried to close any holes, but I’ve a feeling there are a few left. Please note I’m also checking for a variable of ‘isIos’.

Here’s the script:

function getBrowserWidth() {
  $(window).load(function () {
    if (window.innerWidth) {
      return window.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth != 0) {
      return document.documentElement.clientWidth;
    }
    else if (document.body) { return document.body.clientWidth; }
    return 0;
  });
  $(window).resize(function () {
    if (window.innerWidth) {
      return window.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth != 0) {
      return document.documentElement.clientWidth;
    }
    else if (document.body) { return document.body.clientWidth; }
    return 0;
  });
}

function getBrowserHeight() {
  $(window).load(function () {
    if (window.innerHeight) {
      return window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight != 0) {
      return document.documentElement.clientHeight;
    }
    else if (document.body) { return document.body.clientHeight; }
    return 0;
  });
  $(window).resize(function () {
    if (window.innerHeight) {
      return window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight != 0) {
      return document.documentElement.clientHeight;
    }
    else if (document.body) { return document.body.clientHeight; }
    return 0;
  });
}

var browserWidth = getBrowserWidth(),
    browserHeight = getBrowserHeight(),
    isIphone = navigator.userAgent.match(/iPhone/i) != null,
    isIpod = navigator.userAgent.match(/iPod/i) != null,
    isIpad = navigator.userAgent.match(/iPad/i) != null,

    isIos = isIphone || isIpod || isIpad;

if (browserWidth <= 1024 && isIos) {

} else if (browserWidth > 800 && browserWidth <= 1024 && !isIos) {

} else if (browserWidth <= 1024 && browserHeight <= 768 && !isIos) {

} else if (browserWidth > 1024 && browserWidth <= 1280) {

} else if (browserWidth > 1024 && browserWidth <= 1280 && browserHeight <= 720) {

} else if (browserWidth > 1280 && browserWidth <= 1600) {

} else if (browserWidth > 1280 && browserWidth <= 1600 && browserHeight > 768 && browserHeight <= 900) {

} else if (browserWidth > 1920 && browserWidth <= 4000) {

} else if (browserWidth > 1920 && browserWidth <= 4000 && browserHeight > 1080 && browserHeight <= 4000) {

} else {

}
  • 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-01T05:24:00+00:00Added an answer on June 1, 2026 at 5:24 am

    if you really want to do this method, then i suggest a cascade comparison from highest to lowest (sort of switch statement). that way, you don’t need ranges:

    var w = $.Window.width();
    
    if(w>4000){
        //greater than 4000
    } else if(w>1920){
        //assumed less than 4000 greater than 1920
    } else if (w>1280){
        //assumed less than 1920 but greater than 1280
    } else if (w>1024){
       //assumed less than 1280 but greater than 1024
    } else if (w>800){
       //assumed less than 1024 but greater than 800
    } else {
       //small sized
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery in my current Rails project and I'd like to have some
Successfully used jquery-infinite-carousel in the past but for my current project I need it
I Want to start a jQuery function when the current Height of the Page
I'm using Jquery UI sortable in my current project to make boxes drag and
I am trying to create a Jquery Tree plugin for my current project. In
My current project requires locating an array of strings within an element's text content,
I'm using the jKey jQuery plugin on a current project. It just allows you
In a current web project, I'm using several jQuery plugins and initializing them just
I would appreciate some help or suggestions with my current project. I have a
I have a spec in my current project that requires us to advise the

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.