Team Site Scroll down middle of the page on load

SGH 1,221 Reputation points
2021-10-26T08:10:14.537+00:00

There is a requirement of Team Site Scroll down middle of the page on load. How to achieve this ?

Under document.ready function of jquery is prefered.

143685-2021-10-26-11-05-02.png

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,561 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,569 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 30,906 Reputation points Microsoft Vendor
    2021-10-27T02:22:05.337+00:00

    Hi @SGH ,
    Office 365 page is always at scrollTop:0 position.
    You will see in the office 365 page that scrolling appears after ribbon gets over. Scrolling doesn't apply for whole page, instead it applies to specific div. While other sites don't have similar scenario and they works with your code.
    so If you see in browser developer tool #s4-workspace is the specific element which has scrolling. So what your script does is move to middle window, which is already at top. We can scroll to middle window using following js code by adjust y-axis.

    	<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>  
    	<script>  
    		$(document).ready(function() {  
    			ExecuteOrDelayUntilScriptLoaded(scrollWin,"sp.js");			  
    		});  
    		  
    		function scrollWin() {  
    			$('#s4-workspace').animate({ scrollTop: 500}, 'slow');  
    			  
    		}  
    	</script>  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. RaytheonXie_MSFT 30,906 Reputation points Microsoft Vendor
    2021-10-27T09:26:59.527+00:00

    Hi @SGH ,
    In modern page, the function should be used to the element $('.is_an_ada2ac09'). The code should be like following

         $(document).ready(function() {  
             setTimeout(scrollWin, 0);              
         });  
              
         function scrollWin() {  
             $('.is_an_ada2ac09').animate({ scrollTop: 500}, 'slow');      
         }