1

We are using below code on our web application master pages inside SharePoint 2003 to make scroll bar position always on top.

function MoveUp() {
            if (window.parent.document.getElementById('WSSMainContainer') != null)
                window.parent.document.getElementById('WSSMainContainer').focus();

            if (window.parent.document.getElementById('MSOPageViewerWebPart_WebPartWPQ2') != null) 
            {
                window.parent.document.getElementById('MSOPageViewerWebPart_WebPartWPQ2').scrolling = 'no';
                window.parent.document.getElementById('MSOPageViewerWebPart_WebPartWPQ2').style.overflow = 'hidden';

                if (window.document.body.scrollHeight > 1400)
                    window.parent.document.getElementById('MSOPageViewerWebPart_WebPartWPQ2').style.height = window.document.body.scrollHeight + 100;
            }
        }
<body onload="MoveUp();"> ....

Now we migrated our application to SharePoint 2013 and the same code we are using is no longer working.

Anyone experience the same issue?

2 Answers 2

2

SharePoint 2010 and 2013 scroll within a div called s4-workspace not within the parent window. Based on looking at your script coming from 2003, I think this might need a major re-work...

Here are some examples of other questions that have dealt with scrolling issues that have a lot of good background on how scrolling works in modern installations (since it's non-standard... thanks Microsoft!):

Of particular note, in the 3rd link you'll see this line, that might help with what you're trying to accomplish:

document.getElementById("s4-workspace").scrollTop

You should be able to set that to 0 in order to make sure you're at the top of the page, but I'm less sure what you'll need to modify to recreate the inner-webpart behavior from the original.

0

Adding a simple jQuery to this works like a charm in SharePoint !!

$("#s4-workspace").animate({ scrollTop: 0 }, 500);

Late answer though !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.