Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts

    Exclamation Go to the top of the page.

    How do I jump to the top of a page from the bottom of the same page.

    I used to know, but my leaky memory has let it get away.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,749
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hi Frank,
    Search for anchors in this forum, a google search will likely turn up some stuff too.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New Coder
    Join Date
    May 2009
    Location
    Cincinnati
    Posts
    45
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Give an element the ID "top".

    Code:
    <a href="#top">Top<a/>
    When that link is clicked, the page will jump to where the element with the ID "top" is located.

    Alternatively you could use Javascript:

    Code:
    <script type="text/javascript">
        function toTop() {
            self.scrollTo(0, 0)
        }
    </script>
    
    <a href="javascript: toTop();">Top</a>

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by Relish View Post
    Give an element the ID "top".

    Code:
    <a href="#top">Top<a/>
    When that link is clicked, the page will jump to where the element with the ID "top" is located.

    Alternatively you could use Javascript:

    Code:
    <script type="text/javascript">
        function toTop() {
            self.scrollTo(0, 0)
        }
    </script>
    
    <a href="javascript: toTop();">Top</a>
    No need for javascript. You were on the right track but not entirely.

    @Frank I assume you are talking about your sources page. Add this link to the bottom of your page.
    Code:
    <a href="#container">Top</a>
    There problem solved. Clicking the link will go back to the beginning of your #container element.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    May 2009
    Location
    Cincinnati
    Posts
    45
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Not trying to be impolite, just wondering how I was off track..

    And Happy Birthday Aerospace

  • #6
    Regular Coder
    Join Date
    Feb 2007
    Location
    Canada
    Posts
    924
    Thanks
    10
    Thanked 56 Times in 55 Posts
    Quote Originally Posted by Relish View Post
    Not trying to be impolite, just wondering how I was off track..

    And Happy Birthday Aerospace
    Javascript mayy not be available if the Client turns it off, and the CSS / HTML reply will do the same thing without the need for javascript.

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    The first method shown at http://www.dynamicdrive.com/dynamici...markscroll.htm is a good one, which uses a progressive enhancement approach.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #8
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Thanks Aero. Works fine.

    It's here.


    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #9
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Works fine.
    No, at least in FF. It's case sensitive, so use it like
    Code:
    <a href="#Container">Top</a>
    to match with your containers id attribute (or just do the reverse).
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #10
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Quote Originally Posted by abduraooft View Post
    No, at least in FF. It's case sensitive, so use it like
    Code:
    <a href="#Container">Top</a>
    to match with your containers id attribute (or just do the reverse).
    Thank you abduraooft. It there anything that I can do to equalise the text size between the browsers? I like the size that IE8 gives.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #11
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You need to set a default font-size on the body. Setting a font size in px will probably get you similar sizes on different browsers however IE users, not sure about IE8 will not be able to change their font size. I think IE7 has this issue as well. I know IE6 does.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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