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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:39:47+00:00 2026-05-30T18:39:47+00:00

I created a JavaScript overlay function with a re-size listener. Everything works except when

  • 0

I created a JavaScript overlay function with a re-size listener. Everything works except when there’s a scroll. Lets say the screen is 1024×768 but the website’s content takes up 1500×700, so there’s only a vertical scroll. Which JavaScript function can detect the amount of scroll so it can be covered by the overlay? Because right now JavaScript detects 1024×768 and when I scroll, the overlay stops. (If the body background is white and over overlay is black, it’ll display black for 1024 but for the remaining 476px, white is displayed.) Below is my code, I’ve cut it down to the relevant sections. After that has been solved, any tips for IE support would be appreciated. So far it doesn’t render correctly in IE 8.

//Index.html
renderOverlay("image.jpg");


//Overlay.js
renderOverlay(img){
  if(resizeListener){ //global variable
    var overlay = document.createElement("div");
    overlay.className = "overlay"; //Contains overlay background color, positioning etc
    overlay.id = "overlay";
    overlay.style.width = getWindowSize("width");
    overlay.style.height = getWindowSize("height");
    overlay.innerHTML = "<img src='"+file+"' />";

    document.appendChild(overlayWrapper);
    window.addEventListener("resize", function(){renderOverlay(img)}, false);
  }else{
    document.getElementById("overlay").style.width = getWindowSize("width");
    document.getElementById("overlay").style.height = getWindowSize("height");
  }
}


//getWindowSize.js
getWindowSize(dimension){
  if(typeof(window.innerWidth) == "number"){
    if(dimension == "width"){
      return(window.innerWidth+"px");
    }else{
      return(window.innerHeight+"px");
    }
  }
}

//CSS
.overlay{
background: rgba(0, 0, 0, 0.8);
left: 0;
overflow: auto;
position: fixed;
text-align: center;
top: 0;
 }
  • 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-30T18:39:48+00:00Added an answer on May 30, 2026 at 6:39 pm

    You could use CSS to fix the position of the overlay:

    #overlay {
        position: fixed;
        top: 0;
        left: 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a javascript class as follow: var MyClass = (function() { function myprivate(param)
I've created a javascript function that allows me to validate if one field or
I've created a javascript function that will take a hidden span, copy the text
I've created a Javascript object via prototyping. I'm trying to render a table dynamically.
I've created a JavaScript object to hold onto a value set by a user
I have created two JavaScript files. One file is "validators.js" and the other is
I have an array I've created in JavaScript. The end result comes out to
Can I edit a cookie created by JavaScript with PHP and vice versa?
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
I understand that Firefox addins can be created in Javascript and Chrome. How do

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.