• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 663
  • Last Modified:

scrollIntoView scroll the whole page

Hi,

I am trying to use the scrollIntoView function for a boxlist element.
The problem is that in the first time  its scrolls the whole page, and only after that it scrolls the list.
0
VapiSoft
Asked:
VapiSoft
  • 3
1 Solution
 
Justin MathewsCommented:
Can you post the source HTML?
0
 
VapiSoftAuthor Commented:
The HTML is huge so I cannot post it, but the code that does it is very simple.

The attached code is a function that checks that a list has more items that it can hold, and then it sets the overflow to 'auto' and scrolls the 'last_selected_object' into view.
function setScrollbarState(name,last_selected_object)
{
 var obj=document.getElementById(name);
 obj.style.overflowY='hidden';
 if ((obj.scrollHeight-obj.offsetHeight) > 6) 
 {
  obj.style.overflowY='auto';
  if (last_selected_object)
  {
   var obj=document.getElementById(last_selected_object);
   if (obj) obj.scrollIntoView(true);
  }
 }
}

Open in new window

0
 
VapiSoftAuthor Commented:
I found out that the problem happens only when the parameter is true.
So, although it does not scroll to the object (exactly) , I now use false.
0
 
VapiSoftAuthor Commented:
I works, but without the 'true'.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now