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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:24:09+00:00 2026-06-07T17:24:09+00:00

Is re-sizing DIVs on window-resize with Javascript too heavy for most browsers/computers? I’m doing

  • 0

Is re-sizing DIVs on window-resize with Javascript too heavy for most browsers/computers? I’m doing this, because just setting widths in percentages only works in relation to the parent element. I can’t seem to make it a percentage of the body, without regard to other parent elements between (on the DOM tree) the elements I would like to resize and the body.

function resize_columns() {
  var d = getWindowSize();
  var body_width = d.x;
  var fch_width = body_width * .15;
  var pnh_width = body_width * .25;
  $('.for_customer_div').css('width', fch_width + 'px');
  $('.for_customer_header').css('width', fch_width + 'px');
  $('.project_name_header, .project_name_div').css('width', pnh_width + 'px');
  $('.line_item_div').css('width', pnh_width + 'px');
}
$(document).ready(function() {
  resize_columns();
});
$(document).ready(function() {
  window.onresize = function(event) {
    resize_columns();
  }
});

function getWindowSize() {
  var w = window,
  d = document,
  e = d.documentElement,
  g = d.getElementsByTagName('body')[0],
  x = w.innerWidth || e.clientWidth || g.clientWidth,
  y = w.innerHeight || e.clientHeight || g.clientHeight;
  var dimensions = {
    x: x,
    y: y
  }
  • 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-07T17:24:11+00:00Added an answer on June 7, 2026 at 5:24 pm

    Try adding something like this in your code:

    function throttle (func, wait) {
        var throttling = false;
        return function(){
            if ( !throttling ){
                func.apply(this, arguments);
                throttling = true;
                setTimeout(function(){
                    throttling = false;
                }, wait);            
            }
        };
    }
    

    And then call:

    window.onresize = throttle(function() {
        resize_columns();
    }, 20);
    

    This will limit the number number of times resize_columns will be called to a maximum of once every 20 milliseconds.

    Explanation:

    The throttle function accepts two parameters: the function you want to execute, and a timeout duration. It then returns a new function with a reference to the throttling variable, which acts as a flag. So, as far as onresize is concerned, throttle just looks like the inner function it returns. Every time that function is executed, it says “is throttling set to false?”. And if it is, it goes ahead and executes your function. Then it sets throttling to true and creates a setTimeout that will wait x number of milliseconds before it sets throttling back to false. If it gets executed and throttling is set to true, it doesn’t do anything.

    So the basic effect is that, at most, your function can only be executed once in a given time window. So you’re just rate-limiting.

    I know that might not be a great explanation, but I think a full-blown overview of closures would be biting off a little more than I’m willing to chew this morning.

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

Sidebar

Related Questions

I've created this simple demo because I'm having some trouble making auto-sizing work in
so I have created this popup window with a custom move and sizing, pressing
Is this CSS for sizing an <img> to 100% height and maintaining the ratio
I just discovered the box-sizing: border-box CSS property which solves a bunch of cross
I think Window.addResizeHandler is a last resort to resize widgets according to the size
I am having difficulty getting 3 divs to automatically resize when resizing the browser
I've got two sizing issue regarding a Window I've got. The basic layout is
I'm trying to get a SmartGWT Window sizing based on its contents. The correct
When using box-sizing: border-box, it causes the close button to be cut off. This
When using box-sizing: border-box in CSS, I assume that the total width of an

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.