Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    Member #
    52924

    How do I make a webpage load to a specific part of the page

    I have a pretty big family tree page and the center node is at the top center part of the page; youd have to scroll to right a bit to see where this tree begins. How could I get the page to load to that part of the page with the onload function?

  2.  

  3. #2
    Banned
    Join Date
    Dec 2015
    Posts
    75
    Member #
    52817
    Liked
    7 times
    Can you put the code on which you want to implement it?

  4. #3
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    No need for jQuery here:
    HTML Code:
    window.onload = function(){
         var el = document.getElementById('target-element');
         var rect = el.getBoundingClientRect();
         var offsets = {
            top: rect.top + document.body.scrollTop,
            left: rect.left + document.body.scrollLeft  }
    
         document.scrollLeft = offsets.left;
         document.scrollTop = offsets.top; /* If you need it to scroll down as well */
    }
    Last edited by Ronald Roe; Jan 28th, 2016 at 08:21 AM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  5. #4
    Junior Member
    Join Date
    Jan 2016
    Posts
    11
    Member #
    52924
    OKay so heres an example, If i had a hyperlink on one page formatted like this <a href="index.html#nameofperson"Click here</a> why would it just open the index.html page without going to the specific part of the page with the <div id="nameofperson"></div>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:28 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com