Joust is supplied with 3 index files:
index.htm | This is the main HTML page that contains most of the Joust code and sets up the frames. | |
index2.htm | This page sets up the separate window for Floating Mode. | |
index3.htm | This is the home page of the No-Frames version of your site (if you choose to have one). |
The idea behind this structure is that index.htm is the default filename for the site so that when a user visits your site without specifying a page, index.htm is automatically loaded - opening Joust in Frames Mode. It is very likely that you will want to rename these files. Perhaps your server has a different default page (such as default.htm on IIS). Perhaps you want the default mode of Joust to be Floating Mode, or perhaps you want to leave your default page as it is and only load Joust in Floating Mode when the user clicks a "Menu" button.
If you change the names of any of these three files, then you need to tell Joust about it. You do this in two places. At the top of the initialise function in index.htm you will find the following three lines of code:
var index1 = 'index.htm'; var index2 = 'index2.htm'; var index3 = 'index3.htm';
In index2.htm (or whatever you have renamed it to) you will find the following three lines of code:
var index1 = 'index.htm'; var index2 = 'index2.htm'; var index3 = 'index3.htm';
If you change the names of any of the index files then you will need to change these entries as appropriate.
Note: When Joust switches between modes, it will remember what page the user is looking at and restore that page in the new mode. The exception to this is NoFrames mode which, by default, will go to the page pointed to by index3. If you want NoFrames mode to remember the page as well, you should set index3 to an empty string:
var index3 = '';
By default, Joust will load the page you set as defaultPage in the text frame when it is first loaded. You can dynamically specify any other page by adding the URL of the page you want to load as a search parameter in the URL of index.html. For example, if you wanted to set up a link to our site that took the user directly to the Joust page, you would use http://www.ivanpeters.com/index.html?page=/joust_intro.htm.
A good use for this feature (and the reason it's there) is to cope with the situation where a user goes directly to one of your pages (from a bookmark or a link from another site). All of your pages could have the following chunk of code in the <HEAD> section:
<script language="JavaScript"> <!-- if ((self.name != 'text') && (self.location.protocol != 'file:')) { self.location = '/index.htm?page=' + self.location.pathname; } //--> </script>
What this does is check if the name of the window it is being loaded into is "text". If it is not, and the page has not been opened as a file, then the browser is redirected to index.htm. Placing a "?page=" and the URL of the page at the end of the new URL tells Joust to load the page in its text frame. This way you can be sure that users coming into a page on your site from elsewhere will see your site properly, instead of just one page.
If a page is loaded in this way, Joust will also make sure that the sub menu containing the link to the page is opened and visible in the menu frame as if the user had clicked on it. Note: For this to work, the URL that you supply in the search parameter must match exactly the URL used to define the menu entry. self.location.pathname returns an absolute path to the current document (starting with a / ). If the menu was not defined with an absolute path in the first place, Joust will not be able to find it.
Note: Older versions of Joust did not include the "page=" in the search parameter. This caused a conflict with some web servers and CGI scripts which expect name/value pairs in the search parameter. Joust will still support the old mechanism but it may be removed at some point in the future.
There is a trap to watch for with this. If a user tries to print a page in Netscape 4.0.x, the browser reloads the page in a separate, invisible 'printing' window. When it does this, it also re-executes any JavaScript in the page. The code above will cause the 'printing' window to reload index.html and, since it can't print framesets, Netscape will report that there is nothing to print. The following, more complex, version of the above code will get around this problem:
var navPrinting = false; if ((navigator.appName + navigator.appVersion.substring(0, 1)) == "Netscape4") { navPrinting = (self.innerHeight == 0) && (self.innerWidth == 0);} if ((self.name != 'text') && (self.location.protocol != "file:") && (document.cookie.indexOf('mode=NoFrames') < 0) && !navPrinting) { self.location.href = '/index.htm?page=' + escape(self.location.pathname);}
Netscape provides no way to detect that a page is being printed. So the trick here is to to take advantage of a "feature" of Netscape. When printing, Netscape seems to think that the page has zero size so by checking if the innerHeight and innerWidth properties we can tell if the page is being printed.
This code also has an extra test to see if the current mode is "NoFrames". This allows the same page to be used for Frames, Floating and NoFrames modes.