Accessing Joust Properties and Methods

Introduction

If you are a JavaScript programmer, then you will probably want to write code of your own that accesses the Joust objects and methods. These pages explain some of the functions and methods that are available and how to use them.

The core Joust objects are:

Menu
This object contains the menu, it's data, and various methods for manipulating it. Joust automatically creates a global instance of the Menu object called theMenu. You can have multiple menus,if you wish, just by new instances of the Menu object:
var mySecondMenu = new Menu;
MenuItem
The MenuItem object defines an outline entry. MenuItem objects are stored in the entry array of the Menu object. They are automatically created and destroyed, as required, by the Menu object.
theBrowser
This object has a number of properties that define the current browser and what features it supports.
imgStore
This object stores all the images used by Joust. This is actually a property of the Menu object - allowing each menu to use a different set of images. In versions of Joust older than 2.3, the imgStore was a global object that existed once. Version 2.3 still has a global imgStore object that points to theMenu.imgStore. This is for backward compatibility and will probably be removed in a future version.

You can access the properties and methods of these objects from any page in your site by using the parent method. For example:

parent.theMenu.refresh();

However, you need to be a bit careful with this. It is possible, when the user switches into 'Floating Menu' mode, for your page to load before the menu has. If this happens, then parent.theMenu may not exist when you try to access it, causing a JavaScript error. If you try to access Joust objects while (or just after) a page is loading you may encounter this problem. The following simple test will check to see Joust is loaded:

if (parent.theMenu) {
    //Joust is present so OK to access it's objects.
} else {
    //Joust is not loaded at present.  Set a short timeout and
    //try again in a little while.
}

For those of you thinking "hang on a minute, the floating menu is another window so parent can't point to it" - don't worry. index2.htm creates it's own theMenu and theBrowser variables (in the setGlobals function). If you create extra Menu objects of your own, you should modify this function to create mapped references to them.

The Joust Outliner