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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:24:28+00:00 2026-05-26T01:24:28+00:00

I am using the following code to detect a users screen resolution upon load

  • 0

I am using the following code to detect a users screen resolution upon load and resize and change a containers class accordingly. Therefore allowing me to specify different CSS to elements within that container.

This works great when all content on a page is fully refreshed. However it doesn’t work if I load in new content via ajax since this code is only bound to ‘load’ and ‘resize’.

This ultimately ends with me having to resize the browser in order to get the required class changes to apply to the container.

Is there any way to have it detect the ajax content load and fire accordingly?

$(window).bind('resize load', function(e) {
            // get browser width
            var browserWidth = $(document).width();

            // search for the layout's container to inject the class'es
            var containerDiv = settings.containerDiv;

            // get de current class of the container an insert it to the debug window
            var containerClass = $(settings.containerDiv).attr('class');

            // filling the debug window with the current browser's width
            if(settings.debug=='on') {
                $('#debug #currentWidth').text(browserWidth+'px');
                if(containerClass == "") {
                    $('#debug #currentClass').text('-');
                } else {
                    $('#debug #currentClass').text(containerClass);
                };
            };

            // if statements for each resolution
            if(settings.lower1024=='on'){
                if(browserWidth>311 && browserWidth<1023) {
                    $(containerDiv).removeClass();
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(lower1024, 10);
                };
            } else if(settings.lower1024=='off') {
                if(browserWidth<1023 && browserWidth>311) {
                    $(containerDiv).removeClass();
                };
            };
            if(settings.smartphones=='on'){
                if(browserWidth<310) {
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(smartphones, 10);
                };
            };
            if(settings.over1024=='on'){    
                if(browserWidth>1024 && browserWidth<1279 || browserWidth==1024) {
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(over1024, 10);
                };
            } else if(settings.over1024=='off') {
                if(browserWidth>1024 && browserWidth<1279 || browserWidth==1024) {
                    $(containerDiv).removeClass();
                };
            };
            if(settings.over1280=='on'){    
                if(browserWidth>1280 || browserWidth==1280) {
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(over1280, 10);
                };
            };

            if(settings.over1600=='on'){    
                if(browserWidth>1600 || browserWidth==1600) {
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(over1600, 10);
                };
            };

            if(settings.over1850=='on'){    
                if(browserWidth>1850 || browserWidth==1850) {
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(over1850, 10);
                };
            };

            function lower1024() {
                $(containerDiv).removeClass().addClass('lower1024');
            };
            function smartphones() {
                $(containerDiv).removeClass().addClass('smartphones');
            };
            function over1024() {
                $(containerDiv).removeClass().addClass('over1024');
            };
            function over1280() {
                $(containerDiv).removeClass().addClass('over1280 floating');
            };
            function over1600() {
                $(containerDiv).removeClass().addClass('over1600 floating');
            };
            function over1850() {
                $(containerDiv).removeClass().addClass('over1850 floating');
            };


        });

    };
  • 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-05-26T01:24:29+00:00Added an answer on May 26, 2026 at 1:24 am

    If you want this to just apply to all AJAX requests, you could use ajaxSetup and then set a complete function for all of your AJAX requests. Alternatively, just call your function within the complete or success functions of your individual AJAX calls.

    function doResize(){
        // resize stuff
    }
    
    $(window).bind('resize load', doResize);
    
    // some ajax call
    $.ajax(... 
        complete: function(){
            // stuff
            doResize();
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code within the JCProperty class to retrieve data from a
friends, i am using following code inside asyncTask public class AsycLoaderFromDbAndMapInjector extends AsyncTask {
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I'm using the following code to query a database from my jsp, but I'd
I've been using the following code to open Office Documents, PDF, etc. on my
I am using following PHP code to connect to MS Access database: $odb_conn =
I am currently using the following code to create a web request: Dim myRequest
I'm using the following code, using the SharpZipLib library, to add files to a
I'm using the following code to loop through a directory to print out the
I am using the following code: <?php $stock = $_GET[s]; //returns stock ticker symbol

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.