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

The Archive Base Latest Questions

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

I have some code running on my website which will detect if a div

  • 0

I have some code running on my website which will detect if a div with the id, photo, is showing on the screen or is scrolled onto the screen. If the div is showing, a class is added to the div which will cause a background image to load inside the div. The intent is to lazyload the image so that the site loads faster.

It is working great in all browsers except for IE 6/7. Can someone tell me what is wrong with the below code that prevents it from working in these IE browsers?

function $(a){
    return document.getElementById(a)
}
function scrll(){
    function a(d){
        var f=d.offsetTop,
            e=d.offsetLeft,
            c=d.offsetWidth,
            b=d.offsetHeight;
        while(d.offsetParent){
            d=d.offsetParent;
            f+=d.offsetTop;
            e+=d.offsetLeft
        }
        return(f<(window.pageYOffset+window.innerHeight)
            &&e<(window.pageXOffset+window.innerWidth)
            &&(f+b)>window.pageYOffset&&(e+c)>window.pageXOffset)
    }
    if(a($("photo"))){
        $("imgholder").className="pic11 pic21";
        if(window.removeEventListener){
            window.removeEventListener("scroll",scrll,false)
        }else{
            if(window.detachEvent){
                window.detachEvent("onscroll",scrll)
            }else{
                window.onscroll=null
            }
        }
    }
}
if(window.addEventListener){
    window.addEventListener("scroll",scrll,false);
}else{
    if(window.attachEvent){
        window.attachEvent("onscroll",scrll);
    }else{
        window.onscroll=scrll;
    }
}
setTimeout(scrll,1);

The code is active on my website: http://www.ericperrets.info/

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

    IE doesn’t have innerHeight. Use this function instead:

    function getWindowHeight()
    {
        if (window.innerHeight) return window.innerHeight;
        if (window.document.documentElement.clientHeight) return window.document.documentElement.clientHeight;
        return window.document.body.clientHeight;
    }
    

    Also, a good article explaining differences between browsers is at http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

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

Sidebar

Related Questions

I have some code which is been running by a backgroundworker I'd like some
Following the directions at this question , I have some code running to extract
I have some code that attempts to test whether my application is running with
I have some debugging code that if executed while running with GBD attached should
I have some Java code that is throwing out of memory exceptions after running
I have some VBA code that needs to talk to a running c# application.
We have a system that has some Bash scripts running besides Java code. Since
I have some code which collects points (consed integers) from a loop which looks
I have some delphi code which, given a list of items, calculates the total
I have a website which is up and running on drupal. Its product based

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.