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

  • SEARCH
  • Home
  • 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 197761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:52:50+00:00 2026-05-11T16:52:50+00:00

Is there a way to scroll or jump down a page after rendering it?

  • 0

Is there a way to scroll or jump down a page after rendering it?

Specifically, in my controller action, there are some situations where I’ll want to send the user to a particular place on the page. If it were just a link from another page, I’d probably use a URI fragment identifier – “http://blorg.com/page#id” – but this needs to be dynamically generated depending on some condition.

Maybe I need to use JavaScript (Prototype) somehow, but I don’t know how to call the function once the page is done loading, especially from the controller.

  • 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-11T16:52:50+00:00Added an answer on May 11, 2026 at 4:52 pm

    You should really do this type of thing in your view. In your controller you should evaluate your condition to determine the part of the page you want to show, then pass the result into the view. You can then be able to use this information in your view to add a small piece of javascript at the bottom of the page that does something like the following. Of course this doesn’t help you if the user has javascript turned off 😉

    Controller code:

    def index
      # evaluate the condition
      @section = (rand*10).to_i
    end
    

    View view code:

    <div id="#section1">some stuff</div>
    ....
    <div id="#section9">other stuff</div>
    
    <% if @section>0 %>
    <script type="text/javascript">
    // <!--
    document.location.hash="#section<%= @section %>";
    // -->
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to scroll screen to previous position after DropDownList (or other
Is there a way to maintain scroll position after a postback in visual studio
Is there a way to program a Scroll wheel turn on the Windows platform
Is there any way to enable horizontal scroll-bar whenever necessary? The situation was as
Is there any way to change the entire width of the horizontal scroll bar
Is there a way to force IE7 to show a scroll bar even when
Is there any way, in Python, to programmatically change the CAPS LOCK/NUM LOCK/SCROLL LOCK
There is a way to keep the scroll on bottom for a multi line
Is there any way to determine if the mouse scrolls up or down using
is there way thats i can preselect an item when the page loads or

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.