|
July 2001 (Part III)
I've been experimenting with JavaScript-generated menu options.
The key to these is to try and create options from a menu
system without having to refresh the page. Here's my first
attempt at it:
Please click on one of the above menu
options to produce a sub-option, and click it again
to contract it. Isn't that great! The source code is given
on the right-hand side, if you're interested.
My background is in programming, so I actually
feel quite comfortable in produce JavaScript code (even
though the main code was taken from a WWW page that I downloaded).
The key to WWW page design is to notice links that you find
appealing, and then look at the code that has produced this.
With server-side includes, such as ASP and PHP, it is not
possible to view the code, as the server replaces the ASP
or PHP with HTML code. With client-side includes, such as
JavaScript and VBScript it is possible to look at all of
the inserted code, and reuse it. So if you see a nice page,
save it to your local drive, and then use Macromedia Dreamweaver
or Microsoft FrontPage to view the code.
If you're interested, here's a sample screen
shot from the menu option that is given above (just for
the record, as there's a good chance it could change soon):

and here's another one:

If you click on them you should get a larger
version.
Featured page
Well I've got a little bit of column space
left to justify the columns, so I've decided to feature
a couple of screen shots from the Networking quiz. These
are shown on the right-hand side of the page. If you're
interested in going to this page, this click here
(oh dear, I'm really struggling to fill the rest of this
column).
|
The JavaScript is added to the page with:
|
<script language=JavaScript
src="homepage.js"></script>
<script language=JavaScript src="menu.js"></script>
<script language=JavaScript> showHomePage();
</script>
|
The menu.js file contains the menu options.
A sample of it is:
|
function buildNavigation()
{
addCategory("BOOKS", "Books",
false, "My Books");
addCategoryLink("BOOKS", "Adv.
PC Architecture", "computing_book.html");
;;;; etc
addCategory("SUBJECTS", "Taught subjects",
false, "Subjects taught");
addCategoryLink("SUBJECTS", "CNDS",
"cnds.html");
addCategoryLink("SUBJECTS", "NOS",
"nos.html");
addCategoryLink("SUBJECTS", "Comp Eng",
"cengii.html");
;;;;; etc
}
|
The homepage.js file contains the addCategory() and addCategoryLink()
functions, as given next:
|
function addCategory(CatIDStr,
CatStr, defaultShow, Overlay)
{
sImg = defaultShow? "minus.gif" : "plus.gif";
sStyle = defaultShow? "black" : "none";
SubStr = "<!--CATEGORY_LINKS-->";
if (hpStr.indexOf(SubStr) >= 0)
{
SrcStr = "<DIV STYLE='cursor:hand;'"
+
" ID=I_" + CatIDStr +
" onClick=clickCategory(" + char34 + CatIDStr
+ char34 + ") ALIGN=middle BORDER=0> "
+
"<A STYLE='color:black;text-decoration:none;'"
+
" HREF='noop' " +
" Title=" + Overlay +
" onfocus=" + char34 + "window.status='';"
+ char34 +
" onmouseover=" + char34 + "window.status='';"
+ char34 +
" onclick=" + char34 + "window.event.returnValue
= false;" + char34 + ">" +
"<B>" + CatStr + "</B></A><BR>"
+
"<DIV STYLE='display:" + sStyle + ";'"
+
" ID=T_" + CatIDStr +
" onClick=" + char34 + "window.event.cancelBubble=true;"
+ char34 + ">" +
"<DIV STYLE='margin-left:12;'><FONT
SIZE=1><!--" + CatIDStr + "-->"
+ "</DIV>" +
"</DIV></DIV>" + SubStr;
hpStr = hpStr.replace(SubStr, SrcStr);
}
}
|
and addCategoryLink():
|
function addCategoryLink(CatIDStr,
CatStr, LinkUrl)
{
SubStr = "<!--" + CatIDStr + "-->";
if (hpStr.indexOf(SubStr) >= 0)
{
SrcStr = " <A
HREF='" + LinkUrl + "'><FONT COLOR=BLUE>"
+ CatStr + "</FONT></A><BR>"
+ SubStr;
hpStr = hpStr.replace(SubStr, SrcStr);
}
}
|
Screen-shots from networking quiz:


|