Forums

Jumping to middle/end of a long page on load (3 posts)

  1. tdhammer
    Member
    Posted 2 years ago #

    I created a template page that queries a database table and builds a list of the table contents ordered by date. I would like the current month (or the next month with entries) to be the "default" view when the page is accessed. I figure it should be easy to add anchors as I am creating the page from the database table, but how do I get the page to jump to the month of interest when it is loaded.

    You can view the existing page here.

    Any help would be greatly appreciated.

  2. jceresini
    Member
    Posted 2 years ago #

    You can use javascript in an onload function like follows:

    <body onload="window.location.hash='anchor_name';"> [...]

    That should cause the user to be moved to the top of the anchor when the browser finishes loading the page

  3. tdhammer
    Member
    Posted 2 years ago #

    Thanks. I did not think of that since my <body> tag was included in the page from header.php/get_header(). Just made a copy of the header code in this page and added the onload attribute.

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.