Update sync_site.yml
[m6w6/m6w6.github.io] / _posts / 2004-08-02-scrollable-overflowauto-elements-in-mozilla.md
1 ---
2 title: Scrollable overflow:auto Elements in Mozilla
3 author: m6w6
4 tags:
5 - WEB
6 ---
7
8 Doing some extensive Javascript work lately, I managed to make HTML elements
9 styled with //overflow:auto// scrollable in Mozilla.
10
11
12
13 Just place this snippet at the bottom of your page with DIV elements that have
14 scroll as classname:
15
16
17 ```js
18 // enable scrolling for overflow:auto elements in Mozilla
19 function scrollMe(event)
20 {
21 var st = event.currentTarget.scrollTop;
22 st += (event.detail * 12);
23 event.currentTarget.scrollTop = st < 0 ? 0 : st;
24 event.preventDefault();
25 }
26 if (document.body.addEventListener) {
27 var divs = document.getElementsByTagName('DIV');
28 for (var d in divs) {
29 if (divs[d].className && divs[d].className == 'scroll') {
30 try {
31 divs[d].addEventListener(
32 'DOMMouseScroll', scrollMe, false);
33 } catch (ex) {}
34 }
35 }
36 }
37 ```
38
39
40 I already posted a feature request to embed something similar in pearweb.