Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I made a blogging web site using asp.net c#. I have a link '5 comments' on index page. I want that when this link clicked then redirect to comments page and automatically scroll down to comments section. plz help
Posted
Comments
Sergey Alexandrovich Kryukov 16-Sep-15 0:22am    
Do you mean scrolling down to the very bottom of a scrollable element, or not? Do you already know how to make some element scrollable?
—SA

Suppose you have comment section at the very bottom of your page, so while you load the page you have to scroll down to comment section using jquery scrollTop.
Here is a sample html code with jquery for your help, it will automatically scroll to comment area with a nice smooth animation.

XML
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $('html, body').animate({
            scrollTop: $("#commentArea").offset().top
        }, 2000);
    });
</script>
<button id="click">Click me</button>
<div id="mainArea" style="height: 1000px; width: 100px">
    Main Section
</div>
<br />
<div id="commentArea" style="height: 1000px; width: 100px">
    Comment Section
</div>
</html>
 
Share this answer
 
you can use floting div for dynamically scrool down pages

or you can see this following link for working on the floating div.

http://www.c-sharpcorner.com/UploadFile/cd7c2e/create-a-floating-div-which-will-come-up-and-down-automatica/
 
Share this answer
 
C#
$("#commentBtn").click(function() {
    $('html, body').animate({
        scrollTop: $("#comments").offset().top
    }, 2000);
});

This will smoothly scroll down your page to the comment section.

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900