Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    Question Help with Top of Page Javascript


    At the above URL if you scroll down the page a little bit on the left bottom of the site you will see a image appear with an up arrow. If you click it it takes you to the top of the page. Could someone give directions on installing this script on a website. I would like to add this feature to my website.

    Thanks in advance for the help

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,700 Times in 2,676 Posts
    This is not Javascript but straightforward HTML.

    The page top is located by an anchor

    <p><a name="Pagetop"></a></p>
    and then whereever you want the image (top.gif) to appear

    <p><a href="#Pagetop"><img src="top.gif" alt ="Go to top of page" title ="Go to top of page" width="54" height="29" border = "0" ></a></p>
    You can if you wish refine this by placing the image within a <div> which is styled "display:none" which changes to style.display="" on some event, say onmouseover another <div>.

    It is very difficult to reliably capture the scrollbar position cross-browser and that is hence not recommended.

    BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the green "Thank User For This Post" button.

    "Remember that there is nothing stable in human affairs; therefore avoid undue elation in prosperity, or undue depression in adversity". Socrates - Greek philosopher in Athens (469 BC - 399 BC)
    Last edited by Philip M; 05-26-2011 at 08:12 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts