How to make sure the browser will go back to the place of the image after clicking the image with a link in SharePoint page?

Alen CAO 25 Reputation points
2023-05-15T04:33:24.6+00:00

Hi MS,

I created a page in SharePoint and I made several sections with images within each. I configured links for some images so that it will navigate user to specific website in the same tab after clicking the image.

However, when user 'Click to go back' from the browser, it will always return to the top of the SharePoint page instead of the place of the image they just clicked. It's easy to lose user's focus.

How can I do with this? I guess there is a way to automatically append the anchor point link when user is scrolling the SharePoint page so that when they 'Click to go back' after clicking the image with a link, it will return to the anchor point.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,002 questions
0 comments No comments
{count} vote

Accepted answer
  1. RaytheonXie_MSFT 32,476 Reputation points Microsoft Vendor
    2023-05-15T09:34:23.49+00:00

    Hi @Alen CAO ,

    If the content is loaded after page "load" event firing, then the back button would not take you back to the position you were. Because the browser scrolls before the 'load' event.

    To make the browser remember the scroll position in this case, you have to store the scroll position and status (what content have been loaded) somewhere before navigating away. Either in the cookie, or in the url hash.

    If pageA is just a static page without dynamic content (loaded after 'load' event, the browser should remember the scroll position when you go back.

    For dynamic content, there at least includes two parts. One is recovering the page status when click "Back" button, so all the dynamic content is loaded, some expander are expanded or collapsed. The other is scroll to there.

    The first part depends on how the page is implemented. The 2nd part you can put the scroll top into the cookie when page doing onUnload. For example

    $(window).unload(function() {$.cookie('scrollTop',$(window).scrollTop());});
    
    

    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.


0 additional answers

Sort by: Most helpful