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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:41:06+00:00 2026-05-26T20:41:06+00:00

I am using jquery to place an overlay over a div while I am

  • 0

I am using jquery to place an overlay over a div while I am waiting for my server to return to my a json table that I automatically over to (there are two tabs, when you do an ajax post on one, a table is created using JSON data from the server response).

That seems to be working just fine.
However, when I resize my screen, the overlay stays the same size.
That is no good.

That overlay div needs to resize when someone shrinks or expands the window.
I have tried a couple of different things, including posting here to stack overflow.

Also, I tried to attach the size of my div overlay to a $(window).resize function inside of my overlay function.

Basically setting the top, left, width and height css attributes to the div.outerWidth(), outerHeight(), left, top properties.

That doesn’t seem to work.

Any ideas?

CODE for what I Do

        $('<div id="overlay">').css({
        position: 'absolute',
        opacity: 0.2,
        top : $div.offset().top,
        left : $div.offset().left,
        width : $div.offset().width,
        height : $div.outerHeight(),
        background: 'blue url(<%=Url.Content("~/images/ajax-loader.gif")%>) no-repeat center'
    }).hide().appendTo('body');

As you can see, I pretty much do all of my css work inside of a javascript function. I guess I could do all of css stuff in a style sheet like you guys suggest and just append and hide my div to the DOM. I will give it a try.

  • 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-26T20:41:06+00:00Added an answer on May 26, 2026 at 8:41 pm

    Good Answers fellow stack Overflow enthusiasts. I recently solved the problem by simply attaching the overlay to the correct div instead of trying to overlay it over that div and then calculate the size… Here is what I did. There is a subtle change that i will point out.

    function MRNSearchInternals()
    {
        //debugger;
        var form = $("#MRNSearch");
        $div = $("#TabView1");
        var srlzdform = form.serialize();
        var PopID = <% =PopID %>;
        var options = [];
        var $url = $("#target").attr("action");
        $('<div id="overlay">').css({
            position: 'absolute',
            opacity: 0.2,
            top : $div.offset().top,
            left : $div.offset().left,
            width : $div.outerWidth(),
            height : $div.outerHeight(),
            background: 'grey url(<%=Url.Content("~/images/ajax-loader.gif")%>) no-repeat center'
        }).hide().appendTo($div);    
    
        $("#overlay").fadeIn();
        $.post('<%:Url.Action("SearchByMRN", "PatientACO")%>', srlzdform, function (data) 
        {                   
            DisplayDemographicSearch(data);
            $("#overlay").fadeOut('slow', function () {
                 $("#overlay").remove();
            });
        });
    }
    

    Previously, I attached the overlay div to ‘body’. Now I attach it to the div that I previously grabbed… $div… I have know idea why that worked, but the overlay now grows and shrinks with the window size. Any insight into that guys? It would be great to not only have solved this problem, but I would like to learn why the problem was solved as well so I can make a more informed decision next time. Thanks for all of your comments.

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

Sidebar

Related Questions

I'm putting together a fixed, one-page site that deploys an overlay using jQuery. There
I am using a jQuery jEditable edit-in-place field but when the JSON function returns
Using jQuery, is there a way to select all tag that reference a specific
Using jQuery I get JSON object that extracts one row from database. That row
I am using JQuery Overlay from FlowPlayer. I have this that opens my overlay:
I am using a jQuery plugin that has an event handler whose return function
i'm using jquery to place video with flowplayer skin in a hidden div in
How to insert <div> within a <td> using JQuery and place all the child
When using jQuery to submit a form is it possible to place the resulting
I'm using jQuery to take the value of a form element and place it

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.