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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:31:13+00:00 2026-05-24T05:31:13+00:00

i have created a transparent popup with a text box.but the transparent window is

  • 0

i have created a transparent popup with a text box.but the transparent window is of fixed size. i want to increase size of transparent popUp according to html page on which show popUp.

i have used this script :
http://www.pat-burt.com/csspopup.js

style used is:

#blanket {
    background-color:#111;
    opacity: 0.65;
    filter:alpha(opacity=65);
    position:absolute;
    z-index: 9001;
    top:0px;
    left:0px;
    width:100%;
}
#popUpDiv {
    position:absolute;
    background-color:#eeeeee;
    width:300px;        
    height:300px;
    z-index: 9002;
}

i am using this script for onload() event

please help and provide some advice or reference.

Thanks to all

  • 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-24T05:31:15+00:00Added an answer on May 24, 2026 at 5:31 am

    The script needs to be re-written to allow for a dynamic popupDiv size, be it a percentage or simply a larger fixed value.

    The lines causing problems are:

     24    popUpDiv_height=blanket_height/2-150;//150 is half popup's height
    

    and

     43     window_width=window_width/2-150;//150 is half popup's width
    

    In my revised script I changed said lines to:

     23     var popUpDiv = document.getElementById(popUpDivVar);
     24     
     25     // We have to take popup div's height dynamically
     26     var revertHidden = false
     27     if (popUpDiv.style.display == "none") {
     28         // Since it's hidden, show it first
     29         popUpDiv.style.display = "block"; 
     30         revertHidden = true
     31     }
     32     popUpDiv_height=blanket_height/2 - popUpDiv.offsetHeight/2
     33     if (revertHidden) {
     34         // We have to hide it again
     35         popUpDiv.style.display = "none"
     36     }
    

    and

     56     // Here we also need popup div's width dynamically
     57     var revertHidden = false
     58     if (popUpDiv.style.display == "none") {
     59         // Since it's hidden, let's show it
     60         popUpDiv.style.display = "block";
     61         // store that it we have to revert to hidden
     62         revertHidden = true;
     63     }
     64 
     65     // here we use offsetWidth
     66     window_width=window_width/2- popUpDiv.offsetWidth/2
     67     // if it was originally hidden, hide it again
     68     if (revertHidden) {
     69         popUpDiv.style.display = "none";
     70     }
    

    You can use element.offsetHeight and element.offsetWidth to get the height and width of an element, respectively. Thing is, the element needs to be displayed in order to have a height and width. That’s why you have to display it first if it’s not displayed, take the measurement needed, and quickly hide it again. It will occur fast enough such that the user will not notice.

    Once you have that, then the CSS can become (for example):

    #popUpDiv {
        position:absolute;
        background-color:#eeeeee;
        /* Notice we're using a percentage for the height and width */
        width:50%;
        height:50%; 
        z-index: 9002;
    }
    

    EDIT: I’ve updated the code to take into account window resizing. I’ve added a function called window_resize which gets called when the window is resized while the popUp is being displayed. I’ve also decided to play nice and store any existing onresize callback before overwriting it, call it after my window_resize function executes, and restore it when the popup is no longer being displayed.

    function popup(windowname) {
        blanket_size(windowname);
        window_pos(windowname);
        toggle('blanket');
        toggle(windowname);
    
        // Store any previous callback (let's play nice)
        if (window.onresize && window.onresize != window_resize) {
            window_resize.previousCallback = window.onresize;
        }
        // decide if we're going to set window_resize or restore a previousCallback
        var toggledCallback = window.onresize != window_resize ? window_resize : window_resize.previousCallback
        // Set the onresize handler
        window.onresize = toggledCallback
        // set the name of the popupDiv so we can access it from window_resize
        window_resize.popupDiv = windowname;
    }
    
    // This wiil handle our resize event
    var resizeTimeoutId;
    function window_resize(event) {
        window.clearTimeout(resizeTimeoutId);
        resizeTimeoutId = window.setTimeout(function() {
            // resize the blanket
            blanket_size(window_resize.popupDiv);
            // reposition the popup
            window_pos(window_resize.popupDiv);
            // Call the previous onresize callback (if there is one);
            if (window_resize.previousCallback) window_resize.previousCallback.call(window, event);
        }, 10)
    }
    

    I’ve also updated the example at http://so.savantcoding.com/csspopup/. Again the the javascript is viewable at http://so.savantcoding.com/csspopup/csspopup.js

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

Sidebar

Related Questions

I have few doubts regarding transparent AlertDialog box in android.I have created the alert
I have created a non standard shaped window with the WindowStyle=None AllowsTransparency=True Background=Transparent approach.
I have created a placeholder around an <input> field: HTML: <div style=position: relative;font-size: 20px;>
I have a transparent BufferedImage created with the following code(not relevant how it is
I have created some JQuery that will expand a div 'popup' on hover and
I have created a custom post type named People. I have created a page
I have created a function that shows/hides different messages according to a combination of
I have created QLabel *msgLbl . How do I make the msgLbl background semi-transparent?
I have created an AlertDialog using AlertDialog.Builder, but the Dialog border takes up too
I have programatically created a set of ImageButton views (with transparent background) as map

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.