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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:14:12+00:00 2026-05-31T19:14:12+00:00

I was wondering how sites like Facebook, with their timeline feature, float a certain

  • 0

I was wondering how sites like Facebook, with their timeline feature, float a certain element (usually a menu bar, or sometimes a social plugin, etc) when the user has scrolled past a point such that the top of the element is off the screen, etc.

This could be seen as a more general JavaScript (jQuery?) event firing when the user has scrolled to a certain element, or scrolled down a certain number of pixels.

Obviously it would require toggling the CSS property from:

#foo { position: relative; }

to

#foo { position: fixed; }

Or with jQuery, something like:

$('#foo').css('position', 'fixed');

Another way I have seen this implemented is with blogs, where a popup will be called when you reach the bottom, or near the bottom of a page. My question is, what is firing that code, and could you link or provide some syntax/ semantics/ examples?

Edit: I’m seeing some great JS variants coming up, but as I am using jQuery, I think the plugin mentioned will do just nicely.

  • 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-31T19:14:13+00:00Added an answer on May 31, 2026 at 7:14 pm

    Take a look at this jsfiddle: http://jsfiddle.net/remibreton/RWJhM/2/

    In this example, I’m using document.onscroll = function(){ //Scroll event } to detect a scroll event on the document.

    I’m then calculating the percentage of the page scrolled based on it’s height. (document.body.scrollTop * 100 / (document.body.clientHeight - document.documentElement.clientHeight)).

    document.body.scrollTop being the number of pixels scrolled from the top, document.body.clientHeight being the height of the entire document and document.documentElement.clientHeight being the visible portion of the document, a.k.a. the viewport.

    Then you can compare this value to a target percentage, an execute JavaScript. if(currentPercentage > targetPercentage)…

    Here’s the whole thing:

    document.onscroll = function(){
            var targetPercentage = 80;
            var currentPercentage = (document.body.scrollTop * 100 / (document.body.clientHeight - document.documentElement.clientHeight));
            console.log(currentPercentage);
            if(currentPercentage > targetPercentage){
                document.getElementById('pop').style.display = 'block';
                // Scrolled more than 80%
            } else {
                document.getElementById('pop').style.display = 'none';
                // Scrolled less than 80%
            }
        }
    

    ​If you prefer jQuery, here is the same example translated into everybody’s favorite library: http://jsfiddle.net/remibreton/8NVS6/1/

    $(document).on('scroll', function(){
        var targetPercentage = 80;
        var currentPercentage = $(document).scrollTop() * 100 / ($(document).height() - $(window).height());
        if(currentPercentage > targetPercentage){
            $('#pop').css({display:'block'});
            //Scrolled more than 80%
        } else {
            $('#pop').css({display:'none'});
            //Scrolled less than 80%
        }
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how Wordpress and other random forums and sites, like facebook, create
While browsing Facebook pages I was wondering if their bar loads on every request.
I'm wondering how sites like Facebook, and I'm assuming Pinterest does this too (I
I know sites like Facebook are now using REST services, but I am wondering
So I'm wondering how sites like YouTube remember when a user has Liked a
I am wondering how sites like Google sites and shopify allow customers to create
I'm currently creating a facebook-like news feed, and I'm wondering if I'm better off
I want to implement AJAX like facebook, so my sites can be really fast
I am building a tool-bar like umbrella system to link four different sites together
Was just wondering how do these sites (and many other softwares that generate flash

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.