southern walks

Setting an object's properties

If you haven't already done so, read the introduction before continuing.

The string passed to set() consists of a selector, a property and a value. It can be used to set a property of an objext selected by id, or a series of objects selected by class. You can also set the src of an image. For example:

set ('target_div backgroundColor #a9c'); // object selected by id

set ('target_class width 200px'); // objects selected by class name

set ('target_img src images/image1.jpg'); // changes the src of target_image

The last part of the string can also be a global variable. This means that I can apply a calculated value, for example:

var offset;

offset = check ('window width') / 2;
offset = offset + "px";
set ('target_div left offset');

I could also use a value extracted from an array:

var imagearray = new Array (
  "images/image1.jpg",
  "images/image2.jpg",
  .
  .
)

var newimage;

newimage = imagearray[1];
set ('imageholder src newimage');

And I can apply multiple values quickly and easily:

var fontvalue;

fontvalue = "bold 120% arial, helvetica, sans-serif";
set ('target_class font fontvalue');

Setting the class of an object or objects

The property in the string passed to set() can be "class". The script finds the object or objects specified by the selector and changes their class. Let's assume that in your style sheet you've defined two classes, oldclass and newclass. You want to swap oldclass to newclass. So:

set ('target_div class newclass'); // object selected by id

set ('oldclass class newclass'); // objects selected by class name

Class-swapping can be useful when creating mouseover effects.