...

View Full Version : script error help



stereohi
06-11-2003, 09:21 PM
Hi everyone. :)

I am having trouble with a javascript menu I have set up on this page (http://stereohi.tripod.com). While the other menus (blog, info, links) all work, the archive menu will not display and an error comes up when you load the page. The error says there is a ; missing somewhere but I can't find it. Perhaps another pair of eyes will?... or is something else wrong? Here is the code from the page...

the code...


<script language="JavaScript">
<!--
// SHOW/HIDE HIDDEN MENUS
/*from The JavaScript Source - http://javascript.internet.com
Original: Roberto Ortali (ortiz83@libero.it)*/

var Brefer=true;
var Arefer=true;
var Lrefer=true;
var Irefer=true;
function showB() {
if (Brefer) {
document.all.boxB.style.visibility="visible";
Brefer=false;
} else {
document.all.boxB.style.visibility="hidden";
Brefer=true;
}
}
function showA() {
if (Arefer) {
document.all.boxA.style.visibility="visible";
Arefer=false;
} else {
document.all.boxA.style.visibility="hidden";
Arefer=true;
}
}
function showL() {
if (Lrefer) {
document.all.boxL.style.visibility="visible";
Lrefer=false;
} else {
document.all.boxL.style.visibility="hidden";
Lrefer=true;
}
}
function showI() {
if (Irefer) {
document.all.boxI.style.visibility="visible";
Irefer=false;
} else {
document.all.boxI.style.visibility="hidden";
Irefer=true;
}
}

//-->
</script>


the HTML...


<tr class="menu"><td>
<a href="#" onClick="showB(); return false;"><img src="blog-on.gif" name="blog" border="0" width="106" height="26" alt="selected posts" /></a><img src="clear.gif" width="10" />
<a href="#" onClick="showA(); return false;"><img src="arch-on.gif" name="arch" border="0" width="106" height="26" alt="links to archives" /></a><img src="clear.gif" width="10" />
<a href="#" onClick="showI(); return false;"><img src="info-on.gif" name="info" border="0" width="106" height="26" alt="about me" /></a><img src="clear.gif" width="10" />
<a href="#" onClick="showL(); return false;"><img src="links-on.gif" name="links" border="0" width="106" height="26" alt="other blogs and websites" /></a>
</td></tr>


I would really appreciate any help! Thank you! :thumbsup:

stereohi
06-11-2003, 09:24 PM
oops, just read the posting guidelines thread, sorry about that!! :(

arnyinc
06-11-2003, 10:02 PM
Since it only happens with the Archive button, the first thing that comes to mind is to error check that function and it's contents. Try replacing the contents of the div named boxA with some more basic content and see if you still get that error. Embedding that script in there might be the cause of your problem.


<div id="boxA">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="linksA" width="106">test!</td>
</tr>
</table>
</div>

Those 4 functions all do the same thing. You need to reuse your code! :)

stereohi
06-11-2003, 10:29 PM
you're right, it is the embedded code, the test showed up...

It's just strange because it had never not worked before, I haven't altered any code, it just suddenly stopped working...

I've looked over the archive script that I linked to in the box, but I can't find anything missing... but then again I don't know enough about javascript to be able to see much. I just don't understand why it worked before and isn't working now, when I didn't change anything. :confused:

This is the archive script...



// User data
var currentPageName = "current posts";
var currentPageLink = "index.html";
var archivePath = "";
var preLink = "";
var postLink = "";

function ArchivePage_MakeLink(){
var month_name = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var newName = preLink + month_name[this.StartDate.getMonth()]+" "+this.StartDate.getFullYear() + postLink;
var outString = "";

if ( -1 != location.href.indexOf( this.Link ) ){
outString = "<span class=\"archivelinks\">" + newName + "</span><br>";
}
else{
outString = "<a href=\"" + archivePath + this.Link + "\" class=\"archivelinks\">" + newName + "</a><br>";
}
return outString;
}

function ArchivePage( theLink, theName ){
this.Link = theLink;
this.Name = theName;

this.StartDate = new Date( this.Name.slice(6,10), this.Name.slice(0,2)-1, this.Name.slice(3,5) );
this.EndDate = new Date( this.Name.slice(13+6,13+10), this.Name.slice(13+0,13+2)-1, this.Name.slice(13+3,13+5) );

ArchivePage.prototype.MakeLink = ArchivePage_MakeLink;
}


function FindIdx( myURL ){
for ( var n=0; n<BlogInfo.length; n++ ){
if ( -1 != myURL.indexOf( BlogInfo[n].Link ) )
return n;
}
return null;
}

function WriteArchiveSection( BlogInfo ){

var start = 0;
var end = BlogInfo.length;
var currentPage = FindIdx(location.href);

if ( null != currentPage ){ document.write( "<a href=\"" + currentPageLink + "\">" + currentPageName + "</a><br>"); }
for ( var n=start; n<end; n++ ){
document.write( BlogInfo[n].MakeLink() );
}


}
var count=0;
var BlogInfo = new Array();
<Blogger>
BlogInfo[count++] = new ArchivePage( "<$BlogArchiveLink$>" , "<$BlogArchiveName$>" );
</Blogger>

WriteArchiveSection( BlogInfo );

arnyinc
06-12-2003, 05:25 PM
I don't see the MakeLink() function defined anywhere in your code. Should the third to last line of this function be ArchivePage_MakeLink()?


function WriteArchiveSection( BlogInfo ){

var start = 0;
var end = BlogInfo.length;
var currentPage = FindIdx(location.href);

if ( null != currentPage ){ document.write( "<a href=\"" + currentPageLink + "\">" + currentPageName + "</a><br>"); }
for ( var n=start; n<end; n++ ){
document.write( BlogInfo[n].MakeLink() );
}
}

stereohi
06-15-2003, 07:38 AM
thank you so much for replying! I'm sorry its taken so long for me to respond!

I don't know why MakeLink() is not defined, I didn't write the code (I got it from this guy (http://philringnalda.com/) at this page (http://philringnalda.com/scriptgen/)). But I did try what you suggested, changing this....

document.write( BlogInfo[n].MakeLink() );
to this

document.write( BlogInfo[n].ArchivePage_MakeLink() );
but it still didn't work. But MakeLink() still might be the problem... I just wish I knew how to fix it:( I really appreciate everyone's help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum