HTML 4.01 compliant problem with javascript

rockmansattic
rockmansattic used Ask the Experts™
on
I am trying to make my pages compliant with HTML 4.01 and cant seen to work around this bit of Javascript made for breadcrumbs.  Any idea in how to do this?  I have been running it through w3c http://validator.w3.org/ 

***********************CODE********************
<script language="JavaScript" type="javascript">
function breadCrumbs(base,delStr,defp,cStyle,tStyle,dStyle,nl) { // by Paul Davis - http://www.kaosweaver.com
loc=window.location.toString();subs=loc.substr(loc.indexOf(base)+base.length+1).split("/");
 document.write('<a href="'+getLoc(subs.length-1)+defp+'" class="'+cStyle+'">Home</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');
 a=(loc.indexOf(defp)==-1)?1:2;for (i=0;i<(subs.length-a);i++) { subs[i]=makeCaps(unescape(subs[i]));
 document.write('<a href="'+getLoc(subs.length-i-2)+defp+'" class="'+cStyle+'">'+subs[i]+'</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');}
 if (nl==1) document.write("<br>");document.write('<span class="'+tStyle+'">'+document.title+'</span>');
}
function makeCaps(a) {
  g=a.split(' ');for (l=0;l<g.length;l++) g[l]=g[l].toUpperCase().slice(0,1)+g[l].slice(1);
  return g.join(" ");
}
function getLoc(c) {
  var d="";if (c>0) for (k=0;k<c;k++) d=d+"../"; return d;
}
</script>

*********************END******************

The errors are that there are end tags that have not been opened.  such as the </a> in line 4.  

Thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David H.H.LeeDigital Marketing (Hospitality)

Commented:
InStead of
document.write('<a href="'+getLoc(subs.length-1)+defp+'" class="'+cStyle+'">Home</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');

Change to
document.write('<a href='+getLoc(subs.length-1)+defp+'?class='+cStyle+'>Home</a>')
document.write('<span class='+dStyle+'>'+delStr+'</span>');
David H.H.LeeDigital Marketing (Hospitality)

Commented:
Some changes :
var strTmpURL
strTmpURL=getLoc(subs.length-1)+defp
document.write('<a href="'+strTmpURL+'" class="'+cStyle+'">Home</a>')
document.write('<span class="'+dStyle+'">'+delStr+'</span>');
Commented:
Also, the </ combination is not valid inside a script block. Change to:
....Home<\/a>
.....delStr+'<\/span>');

Author

Commented:
Thank you , thats what I needed.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial