Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Chattanooga, Tennessee
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation script error help

    Hi everyone.

    I am having trouble with a javascript menu I have set up on this page. 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...
    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...
    Code:
    <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!

  • #2
    New Coder
    Join Date
    Jul 2002
    Location
    Chattanooga, Tennessee
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oops, just read the posting guidelines thread, sorry about that!!

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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!

  • #4
    New Coder
    Join Date
    Jul 2002
    Location
    Chattanooga, Tennessee
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    This is the archive script...

    Code:
    // 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 );

  • #5
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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() );
    }
    }

  • #6
    New Coder
    Join Date
    Jul 2002
    Location
    Chattanooga, Tennessee
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 at this page). But I did try what you suggested, changing this....
    Code:
    document.write( BlogInfo[n].MakeLink() );
    to this
    Code:
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •