How to set scrollTop on form in backend using Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 02:49 AM
Hi,
is there a way how to set scroll position (scrollTop) using client script on form?
The problem is that when I try to execute .scrollTop() on window object it returns undefined. Maybe it is connected with height of body – which is 100%.
Does somebody have an experience with setting scroll position inside the form iframe using DOM in client script?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 03:16 AM
Hi,
first you need to check if your frame you want to scroll up is the main frame on the page (without /nav_to.do) or an iframe (with /nav_to.do). This is very easy to check by verifying if the frame gsft_main exists.
You can do the following in your Client Script:
if(top.gsft_main){
top.gsft_main.scrollTo(0, 0); // if form is on the sub frame
} else {
top.scrollTo(0, 0); // if form is on the main frame
}
It will return undefined but do the scrolling too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 03:22 AM
Ok, I will try to implement this and let you know,
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 04:32 AM
Unfortunately, this is not working.
I tried to execute top.gsft_main.scrollTo(0, 0); in console, but as before – result is undefined.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 04:42 AM
What kind of result do you expect? It has no return value (always returns undefined) but the scrolling should happen anyway.
See some documentation for reference: https://www.w3schools.com/jsref/met_win_scrollto.asp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 04:52 AM
I need to scroll to top basically. But nothing happens when called via client script or console.