Scroll Layers in a Table

Introduction

This example positions the scrolling layers in a cell of a centered table. The links to the left load new content into the layer for scrolling.

The scroll arrows are activated on mouseover in this example. The file dw_hoverscroll.js adds this functionality to the dw_scrollObj.

If you prefer that the scroll arrows be activated onclick rather than onmouseover, you can use the glide-scroll code instead.

Scrollbars are optional. The files dw_slidebar.js and dw_scroll_aux.js add this functionality to the dw_scrollObj.

Gecko Bug

The code includes a bug fix necessary for Netscape 6+/Mozilla when scrolling vertically in tables. Without this fix the table would shrink and expand while scrolling for all but the most recent versions of Mozilla.

The bug fix is often needed for horizontal scrolling as well. Without it, some Gecko-based browsers will tend to scramble the layout.

The dw_scrollObj.GeckoTableBugFix function removes the scrolling layers from the table and uses the relative positioned containing layer's position to superimpose the layers over the table.

Setting Up the Layers

Div's are nested three deep for scrolling layers inline. The outer-most layer (usually assigned an id of hold or holder) is relative positioned, has width and height settings, and overflow hidden.

The scroll area itself is defined by a "window" div (usually assigned an id of wn or wn1), with width, height and clip settings, and overflow hidden.

The content that scrolls is contained in the innermost div (or div's). You can add as many content layers as you like within any given "window" div.

Scroll areas to be positioned absolute do not require the outermost (hold) layer, although it is often a convenient container for the scroll links.

Note: For best cross-browser cooperation, do not fundamentally change the style specifications for the layers, other than adjusting width and height. Removing clip or overflow settings or changing the position to relative on the window or content layers may cause some browsers to cease functioning properly.

Implementing Scrollbars

You can set up scrollbars using graphics of your choice and adjust their style specifications accordingly.

Notice that the height of the drag bar adjusts according to the amount of content in the layer. This is an optional feature that can be turned off with a simple property setting. See code comments in the head of the document.

The main presentation page for scrolling layers contains more detailed information about the scrollbars and how to set them up.

Multiple Scroll Areas

You can follow the format described and demonstrated in this example to add more than one scroll area. See the example with multiple scrolling areas for guidance. Even though that example uses absolute positioning, the pattern for setting up the layers remains the same. Just remember that all id's need to be unique.

Remember to pass the id's for areas that scroll in tables to the GeckoTableBugFix function so Netscape 6+ and Mozilla will be able to extract their layers and function properly. (See code comments in the head of the document for more information.)

www.dyn-web.com