theEclipse
Programmer
I am working on a website that is mainly centered around ssi, so that I can easily change the interface and look of the website by only changing 3 files. I have one file for the navagation/bottom of the page, one for top, and one for the styles/javascript.
the format for one of my pages goes something like this:
anyway, I have some js code in the bottom.txt file that prints out the navagation from an array. The reason that I dont have it just written in html is I wanted to have the link to the page the user is on to be highlighted. The code works fine on all pages except one, which I get an error that says 'object does not support this property or method'
here is the code (with line highlited in red)
//**--this first large block of code is just an array with the different links and images
//**--this function reads in the above array, and through some fancy string manipulation, makes four more arrays, each with part of a link in it (the href, the text, the opener tag, the closing tag)
//**--all this next function does is print out the link table, with the correct link as just text
//**--the function calls
theEclipse
eclipse_web@hotmail.com
robacarp.webjump.com
**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
the format for one of my pages goes something like this:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Robs Gadget Corner</title>
<!--#include file="styles.txt"-->
</head>
<body bgcolor="#359EFF" background="images/backgroundgrid.gif" text="#086C08">
<!--#include file="top.txt"-->
<!--this is where the content goes-->
<!--#include file="bottom.txt"-->
</body>
</html>
anyway, I have some js code in the bottom.txt file that prints out the navagation from an array. The reason that I dont have it just written in html is I wanted to have the link to the page the user is on to be highlighted. The code works fine on all pages except one, which I get an error that says 'object does not support this property or method'
here is the code (with line highlited in red)
Code:
<script language=javascript>
//**--this first large block of code is just an array with the different links and images
Code:
var preLinkArray=new Array('<a href=\"index.shtml\" class=\"linkTypeA\">Home</a><br>','<a href=\"computers.shtml\" class=\"linkTypeA\">Computers:</a><br>','<a href=\"pranks.shtml\" class=\"linkTypeA"> <img border=0 src=images/bullet.gif align=absmiddle>Pranks</a><br>',' <a href=\"secrets.shtml\" class=\"linkTypeA"><img border=0 src=images/bullet.gif align=absmiddle>Secrets</a><br>',' <a href=\"links.shtml\" class=\"linkTypeA"><img border=0 src=images/bullet.gif align=absmiddle>Links</a><br><br>');
//**--this function reads in the above array, and through some fancy string manipulation, makes four more arrays, each with part of a link in it (the href, the text, the opener tag, the closing tag)
Code:
function lnkAryObj(links){
this.num=links.length;
this.preText=new Array();
this.endText=new Array();
this.linkText=new Array();
this.href=new Array();
for (i=0;i<links.length;i++){
link=links[i];
//this is a verry condensed algorithim, so it is also very confusing!
start=link.substring(0,link.indexOf('class="linkTypeA">')+18);
end=link.substring(link.indexOf('</a>'),link.length);
middle=link.substring(link.indexOf('class="linkTypeA">')+18,link.indexOf('</a>'));
choppedstart=start.substring(start.indexOf('href='),start.length);
beginingofhref=choppedstart.indexOf('"')+1;
Code:
choppedstart=choppedstart.substring(beginingofhref,choppedstart.length);
Code:
endofhref=choppedstart.indexOf('"');
href=choppedstart.substring(0,endofhref)
this.preText[i]=start; this.endText[i]=end; this.linkText[i]=middle; this.href[i]=href;
}
return this
}
//**--all this next function does is print out the link table, with the correct link as just text
Code:
function printLinks(links){
pageLocation=location.href
pageLocation=pageLocation.substring(pageLocation.lastIndexOf('/')+1,pageLocation.length);
if (pageLocation==''){pageLocation='index.shtml'}
for (i=0;i<links.num;i++){
if (pageLocation!=links.href[i]){
document.write(links.preText[i]+links.linkText[i]+links.endText[i]);
} else {document.write(links.linkText[i]+'<br>');}
}}
//**--the function calls
Code:
var linkObj=new lnkAryObj(preLinkArray);
printLinks(linkObj);
</script>
theEclipse
eclipse_web@hotmail.com
robacarp.webjump.com
**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.