Forum Discussion
Scroll Bar start position
As you have multiple scroll panels ( in fact that are the textareas ) the code from Russel grabs all scroll panels/text areas in the Storyline and sets them in this htmlCollection.
The below line does that.var x = document.getElementsByTagName('textarea')[0];
Where x is the htmlCollection ( so all textareas in your Storyline ) and the [0] at the end ensures that only the first entry will be used.
So when you have multiple textareas in your Storyline you need to ensure you target the correct one. Several ways to do that.
One is like this.var scrollAreas = document.getElementsByTagName('textarea');
//First we get all textAreas in a htmlCollection. Russel called that x, but i like more descriptive names.
var scrollArea1 = scrollAreas[0];
var scrollArea2 = scrollAreas[1];
//Then we set all scrollAreas we have to a variable and next we can target them
scrollArea1.scrollTop = (scrollArea1.scrollHeight-scrollArea1.offsetHeight) * 1/2;
scrollArea2.scrollTop = (scrollArea2.scrollHeight-scrollArea2.offsetHeight) * 1/2;
Other way is like this.var x2 = document.getElementsByTagName('textarea')[1];
x2.scrollTop = (x2.scrollHeight-x2.offsetHeight) * 1/2;
Both should work. I prefer the first way as its more organized and clear, but in fact its the same.
Kind regards,
Math
Related Content
- 6 months ago
- 6 months ago