|
I eventually mothballed the help for several reasons:
To start with, the whole thing is written in JavaScript. There is a function in each page which allows it to call the help library, and a single central help library which draws the appropriate entry when called. To pass information between the calling page and the library, I use a cookie. Here comes the science bit. Concentrate.
The Calling DocumentAny page which wants to call the help library needs to have the following code inserted between the <HEAD> </HEAD> tag pair:
Then, every time you want to have a help link, it would look something like this:<SCRIPT> function glossary(entry){ document.cookie = "andyshome=" + entry window.open("glossary.htm","glossary","width=400,height=250") } </SCRIPT> Here's how it works: When you click the link in your document, it calls the glossary() function and passes the value in brackets to it. The glossary function creates a cookie called andyshome with the value that was passed, and then opens the pop-up help library file, which is called glossary.htm.<A HREF="javascript:glossary(1)">Insert your text here</A> This method of passing information between pages is kinda clunky, but it works. It is not as elegant as server-side processing but if your resources are limited - say, by using a commercial free ISP - then it is a handy second-best. Of course if the user is paranoid and has disabled cookies, this does not work.
The LibraryWhen you load the pop-up library, it checks for that cookie that we created, and then creates a text string based upon the value of the cookie.. Here is an example:
There are two functions in this script, some variables, and an array of glossary entries.<HTML> <HEAD> <TITLE>Andy Explains...</TITLE> <SCRIPT LANGUAGE="JavaScript"> // These are some variables that need to be set up for later. var htmlTop = "<BODY BGCOLOR=82E8D0 <" htmlTop += "FONT FACE='Arial'><CENTER><H1>" var htmlMiddle = "</H1></CENTER><P>" var htmlBottom = "<P><CENTER>" htmlBottom +="<A HREF='javascript:window.close()'>Back</A>" htmlBottom += "</CENTER><P></BODY></HTML>" var page = "" function makeItem(title,text){ this.title=title //Title of the glossary entry this.text=text //Text of the glossary entry (long!) } glossary = new Array(2) glossary[0] = new makeItem("JavaScript","A simple scripting language.") glossary[1] = new makeItem("Cookie","A snippet of information from a Web page.") function buildPage(){ var entry = parseInt(document.cookie.substring(10,document.cookie.length)) page += htmlTop page += glossary[entry].title page += htmlMiddle page += glossary[entry].text page += htmlBottom document.write(page) document.close() } </SCRIPT> </HEAD> <BODY onLoad="buildPage()"> </HTML>
The array is a simple list of glossary objects. Each object has two properties: title and text. Add more as you need them.
|
|||||||||