DHTML : Text scrolling
Mikael Le Moal
Initialisation
To make the handling of our layers easier, we have used generic objects. They are defined by the
creerObj function, which is called up twice, once for each layer, when the script begins the initialisation process:
52: // Object creation function
53: function creerObj(obj,cont){
54: if (mie) {
55:
56: this.css=document.all[obj].style;
57: this.scrollHeight=document.all[obj].offsetHeight;
58: this.clipHeight=document.all[obj].offsetHeight;
59: }
60: else {
61: if (cont!='') {
62: cont='document.'+cont+'.';
63: }
64: this.css=eval(cont+'document.'+obj);
65: this.scrollHeight=this.css.document.height;
66: this.clipHeight=this.css.clip.height;
67: }
68: this.haut=haut;
69: this.bas=bas;
70: this.deplace=deplace;
71: this.x=0;
72: this.y=0;
73: eval(this.obj+'=this');
74: return this;
75: }
[...]
110: function Init(){
111: checkbrOK();
112: Container=new creerObj('divContainer','');
113: Texte=new creerObj('divTexte','divContainer');
114: Texte.deplace(0,0);
115: }
The
Init() function begins by detecting the visitor's browser (line 111)and then calls up
creerObj() twice to create the variables that will be used to address and handle the layers (lines 112 and 113). Here are the variables
set by the function:
- this.css, which contains a reference to the layer's style properties.

The method used to access the layers depends on the browser used. This variable provide us with an access method valid in
any cases.
- this.scrollHeight, which contains the layer's height.

- this.clipHeight, which contains the height of the layer's visible area.

In most cases, it equals the layer's height, unless the values of these properties set in the style sheet statement for the
layer are different.
- this.x, which contains the layer's horizontal coordinate.

- this.y, which contains the layer's vertical coordinate.

- this.obj, which represents the current object.

We will take this opportunity to declare the
haut,
bas and
déplace functions. Relieved from the burden of browser detection, they simplify the addressing of layers (lines 68 to 70).
The last task carried out by the
Init() function is to set the
divTexte in its initial position (line 114).