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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:34+00:00 2026-05-23T14:39:34+00:00

I have a header.php which has my <a name=’#top’ /> and I have a

  • 0

I have a header.php which has my <a name='#top' />

and I have a footer.php which I want to do something like

if ($_SERVER[' is scroll bar ']
{
  echo <a href='#top'>Back to Top</a>
}

is it possible with PHP or Javascript to do something like this, where I can know if my page is going to be very long ahead of render time?

  • 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-23T14:39:35+00:00Added an answer on May 23, 2026 at 2:39 pm

    First off, I’m unsure of the practical usefulness of such code. I’m never really certain what a “back to top” or “jump to top” link will do:

    • Will it just send me to the top of the page?
    • Will it send me to some anchor below the top?
    • Will it take me to the top page?
    • Will it reload (sigh)?

    I do know what pressing the Home key will do, though, and I suspect most people would rather navigate a page using native controls if possible.

    Nonetheless, once the page is loaded, you could toggle that kind of link dynamically by setting up event handlers on page resize:

    var toTopLink = document.getElementById("toTopLink");
    
    function checkLink(e) {
      /*
       * document.height                       = works in most browsers
       * document.body.scrollHeight            = needed in IE
       *
       * window.innerHeight                    = works in most browsers
       * document.documentElement.offsetHeight = IE in compatibility mode
       * document.body.offsetHeight            = IE backwards compatibility
       *
       * In most browsers, document.height equals window.innerHeight if there is no
       * scrollbar. For IE, we test whether the scrollable height is greater than the
       * visible document height.
       */
      if ((document.height || document.body.scrollHeight) >
            (window.innerHeight || document.documentElement.offsetHeight ||
             document.body.offsetHeight)) {
        toTopLink.style.display = "block";
      } else {
        toTopLink.style.display = "none";
      }
    }
    
    window.onresize = checkLink;
    window.onload = checkLink;
    

    Different browsers — by which I mean IE versus everyone else — have their own ways of finding height, and so the above accounts for that, maybe somewhat redundantly.

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

Sidebar

Related Questions

I have the following php code, which has been snipped for brevity. I am
I have a PHP script which has the source of an email. I aim
I have a header file which has the html <head> tag in it. I'm
its a little bit hard to understand. in the header.php i have this code:
I have a problem with php header redirect. I already spent hours trying to
I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;
I know in PHP, it sends the X-Powered-By header to have the PHP version.
I have written a very very very simple!! script in php. header redirection not
I have a html_headers.inc.php script that I want to include in every script on
I have a header <h1>My Header</h1> It has a height of 150px and a

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.