KLayers
Manual

Table of contents

What is KLayers

KLayers library is intended for simplification of operation with Dynamic HTML in various browsers. KLayers is a set of JavaScript functions and methods which allow programmer to pay lesser attention to browser's specific features.

For example, to find out height of document contents, the programmer should use variables:

KLayers releases programmer from this routine actions. Using KLayers, you should only call function getDocumentHeight() which returns document's height.

Using KLayers

Including to document

KLayers is a JavaScript program, so it is included by standart tags

<script language="JavaScript" type="text/javascript" src="klayers.js"></script>

Supported browsers?

This version of KLayers supports all main DHTML-browsers:

Other browsers officially not supported.

In case of new DHTML-browsers releasing I will add it's support to new versions of KLayers and you should only download updated version of KLayers.

Is KLayers free?

Yes. KLayers is distributed under the terms of the GNU Lesser General Public License, so you can use it in commercial projects and modify.

Functions and methods

Flags and variables

Browser's version

True, if browser

Reference mark of screen coordinates

You can define variables pageLeft and pageTop to determine reference mark of screen coordinates. Defaults - 0.

Functions

Window and document

Example - scroll document to bottom minus 100 px:
S=getDocumentHeight()-getWindowHeight()-100
if(S>=0) self.scrollTo(S)

Special

Miscellaneous

Classes

Class KLayer

Class KLayer is intended to incapsulating of data and logics for operating with layer properties. For historical reasons we shall name hereinafter the DHTML-object a layer

There is constructor KLayer(layer id), for creating instance you must use function-factory layer(layer id). If we have layer with id mylayer, we call layer("mylayer") to obtain interface to it.

For better compatibility with Netscape 4 I wrote function layerFrom(layer id, path to parent layer) for more quick search of layer in Netscape 4 tree of nested layers. For example, if we have layer zzz nested in layer yyy and yyy nested in xxx, we should call layer zzz as

layerFrom("zzz", "document.layers.xxx.document.layers.yyy")
If browser - not Netscape 4, second argument ignored.

Class KLayer incapsulates following fields and methods:

Example: move hidden layer to position (100, 200) and make it visible:
<div id="mylayer" style="position: absolute; visibility: hidden; left:0px; top: 0px">LAYER</div>
<script>
var L=layer("mylayer")
L.moveTo(100,200)
L.show()
</script>

Class KImage

Class KImage written to image operation in Netscape 4, which hold image objects in tree, if images included to layer.

Constructor - KImage(), but for creating image interface you must use function-factory image(image name). or imageFrom(image name, parent layer path in Netscape 4 DOM)

Examples