Javascript in Head doesn't process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ace214
    New Member
    • Apr 2007
    • 5

    #1

    Javascript in Head doesn't process

    I have a feeling there's some really stupid something I'm doing but for some reason that I can't find at all, the JavaScript in my head tag won't process on one of my pages. Any help will be greatly appreciated while I try to figure it out.

    http://webdrive.servic e.emory.edu/users/jarnol4/public/cc/webprototype/viewer.htm
  • ace214
    New Member
    • Apr 2007
    • 5

    #2
    Ok, so it's not that's in the head, because I've moved it and a my button rollover script to separate scripts in an attempt to isolate the problem. So the it's the my picture changing script that is the problem:
    Here is the script
    Here is the page

    Thanks for any help.....

    Comment

    • DutchKingCobra
      New Member
      • Mar 2007
      • 37

      #3
      hi pal,
      there where a lot of syntax errors :P

      but i have changed some code

      document.getEle mentById("Capti on").innerHTM L = Captions[i];
      instead of
      document.getEle mentById("Capti on").childNod es[0].nodeValue = Captions[i];

      REMOVED:
      if (img != "htm") { //If an img number is passed
      i = img; //Set i to img for next/prev counter
      startingPic = "pics/".concat(i,".jp g"); //Set startingPic for loading in body of page
      }
      else //If no img number is passed (i.e. somone types url)
      startingPic = "pics/000.jpg"; //Start at pic 0, i is already at 0
      *************** ******
      ADDED:
      function firstpicture(){
      if (document.getEl ementById("Pict ure")==null){
      setTimeout('fir stpicture()',10 00);
      }
      else{
      document.getEle mentById("Pictu re").src='pic s/000.jpg';
      }
      }
      setTimeout('fir stpicture()',10 00);

      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
      <html><head>
      <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Emory University Concert Choir: Pictures</title>
      <script type="text/javascript" src="buttonbar.js"></script>
      <script type="text/javascript" src="viewer.js"></script>
      <style type="text/css">
      h1 {color: rgb(51,51,102); font-family: "Verdana"; font-size: 150%; text-align: center}		 /* Heading */
      p.footer {color: rgb(51,51,102); font-family: "Verdana"; font-size: 80%; text-align: center} /* Footer */
      a {color: rgb(51,51,102)}																	 /* Supress Link Colors */
      td.button {width: 16%}																		 /* Button Bar Cells */
      img {border: 0px; display: block; margin-left:auto; margin-right:auto;}																		 /* No image borders */
      </style>
      <script>
        url = window.location.toString(); //Get URL
      img = url.substr(url.length - 3); //Get last 3 characters of URL
      
      Captions = new Array();
      Captions[0]= "Photo 1 of 25";
      Captions[1]= "Photo 2 of 25";
      Captions[2]= "Photo 3 of 25";
      Captions[3]= "Photo 4 of 25";
      Captions[4]= "Photo 5 of 25";
      Captions[5]= "Photo 6 of 25";
      Captions[6]= "Photo 7 of 25";
      Captions[7]= "Photo 8 of 25";
      Captions[8]= "Photo 9 of 25";
      Captions[9]= "Photo 10 of 25";
      Captions[10]= "Photo 11 of 25";
      Captions[11]= "Photo 12 of 25";
      Captions[12]= "Photo 13 of 25";
      Captions[13]= "Photo 14 of 25";
      Captions[14]= "Photo 15 of 25";
      Captions[15]= "Photo 16 of 25";
      Captions[16]= "Photo 17 of 25";
      Captions[17]= "Photo 18 of 25";
      Captions[18]= "Photo 19 of 25";
      Captions[19]= "Photo 20 of 25";
      Captions[20]= "Photo 21 of 25";
      Captions[21]= "Photo 22 of 25";
      Captions[22]= "Photo 23 of 25";
      Captions[23]= "Photo 24 of 25";
      Captions[24]= "Photo 25 of 25";
      
      var i = 0;						  //Setup i
      last = 24;					  //Last pic for easy looping
      function firstpicture(){
      if (document.getElementById("Picture")==null){
      setTimeout('firstpicture()',1000);
      }
      else{
      document.getElementById("Picture").src='pics/000.jpg';
      } 
      }
      setTimeout('firstpicture()',1000);
      function nextPic() { //Next Picture
      	if (i == last) {		 //Loop back to beginning if on last picture
      		i = 0;
      		newPic = "pics/000.jpg";
      	}
      	else {				 //Otherwise, increase to next picture
      		i++;
      		if (i < 10)			 //Filename workaround
      			newPic = ("pics/00").concat(i,".jpg");
      		else
      			newPic = ("pics/0").concat(i,".jpg");
      	}
      	
      	document.getElementById("Picture").src = newPic;
      	document.getElementById("Caption").innerHTML = Captions[i];
      }
      
      function prevPic() { //Previous Picture
      	if (i == 0) {			 //Loop back to end if on first picture
      		i = last;
      		newPic = ("pics/0").concat(i,".jpg");
      	}
      	else {				 //Otherwise, go back to previous picture
      		i--;
      
      		if (i < 10)			 //Filename workaround
      			newPic = ("pics/00").concat(i,".jpg");
      		else
      			newPic = ("pics/0").concat(i,".jpg");
      	}
      
      	document.getElementById("Picture").src = newPic;
      	document.getElementById("Caption").innerHTML = Captions[i];
      }
      
      function firstPic() { //First Picture
      	if (i != 0) {
      		i = 0;
      		newPic = "pics/000.jpg";
      		document.getElementById("Picture").src = newPic;
      		document.getElementById("Caption").innerHTML = Captions[i];
      	}
      }
      
      function lastPic() { //Last Picture
      	if (i != last) {
      		i = last;
      		newPic = ("pics/0").concat(i,".jpg");
      		document.getElementById("Picture").src = newPic;
      	document.getElementById("Caption").innerHTML= Captions[i];
      	}
      }
      
      </script>
      </head>
      <body style="color: rgb(0, 0, 0); background-color: rgb(51, 51, 102); margin: 0px">
      <table style="background-color: rgb(221, 214, 198); text-align: left; margin-left: auto; margin-right: auto; width: 750px;" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td>
      <a href="index.htm"><img alt="" src="logo.gif"></a></td></tr><tr><td>
      <table style="background-color: rgb(51, 51, 102); width: 750px; text-align: center; vertical-align: middle; margin-left: auto; margin-right: auto;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>
      <td class="button"><a href="choir.htm" onmouseover="light('Choir')" onmouseout="unlight('Choir')"><img name="Choir" alt="" src="Choir_unlit.gif"></a></td>
      <td class="button"><a href="director.htm" onmouseover="light('Director')" onmouseout="unlight('Director')"><img name="Director" alt="" src="Director_unlit.gif"></a></td>
      <td class="button"><a href="concerts.htm" onmouseover="light('Concerts')" onmouseout="unlight('Concerts')"><img name="Concerts" alt="" src="Concerts_unlit.gif"></a></td>
      <td class="button"><a href="auditions.htm" onmouseover="light('Auditions')" onmouseout="unlight('Auditions')"><img name="Auditions" alt="" src="Auditions_unlit.gif"></a></td>
      <td class="button"><a href="audio.htm" onmouseover="light('Audio')" onmouseout="unlight('Audio')"><img name="Audio" alt="" src="Audio_unlit.gif"></a></td>
      <td class="button"><a href="pictures.htm"><img name="Pictures" alt="" src="Pictures_lit.gif"></a></td></tr></tbody></table></td></tr></tbody></table>
      <table style="background-color: rgb(221, 214, 198); width: 750px; text-align: center; margin-left: auto; margin-right: auto;" border="0" cellpadding="4" cellspacing="0"><tbody><tr><td><br>
      <table style="color: rgb(51,51,102); font-family: Verdana; font-size: 90%; text-align: center; margin-left: auto; margin-right: auto; width: 742px" border="0" cellpadding="4" cellspacing="0"><tbody><tr>
      <td style="width: 25%"><a href="javascript:firstPic()">First</a> <a href="javascript:prevPic()">Previous</a></td>
      <td style="width: 50%"><a href="pictures.htm">Back to Album</a></td>
      <td style="width: 25%"><a href="javascript:nextPic()">Next</a> <a href="javascript:lastPic()">Last</a></td></tr></tbody></table><br>
      <a href="javascript:nextPic()"><img id="Picture" alt="Picture"></a>
      
      <div id="Caption" style="color: rgb(51,51,102); font-family: Verdana; font-size: 90%; text-align: center">Photo 1 of 25</div>
      
      <br><hr style="width: 100%; height: 2px;"><p class="footer"><a href="http://www.emory.edu/COLLEGE">Emory College</a> | <a href="http://www.emory.edu">Emory University</a> | <a href="http://www.emory.edu/ARTS">Arts at Emory</a> | <a href="http://www.music.emory.edu/">Emory Music Department</a>
      </td></tr>
      </tbody></table>
      </body></html>
      Well i HTH
      It´s not easy to adjust an integrated script.
      let me know
      ps did u wrote it yourself?
      peace

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        Your image has no source.

        Comment

        • ace214
          New Member
          • Apr 2007
          • 5

          #5
          I adjusted the script anyway. It must have been some error. Yes, I'm writing it from scratch. Sorry for the late response- didn't get the subscribe email. Thanks for your help.

          Comment

          Working...