Topic: JavaScript not working

I edited main.tpl to include header html to match the rest of the site. In the header there is a navigation menu that uses javascript rollover effect. In order for it to work the images for the rollover effect are preloaded using javascript. The images are not preloading. I looked at the html source code from the browser and all looks well. Can't figure it out.

2 (edited by Paul 2004-04-20 23:44)

Re: JavaScript not working

Something missing from body onload maybe? There is more chance of somebody working it out if you could post a link.

Re: JavaScript not working

Ok, actually there are 2 problems. First the image preload problem as I already described. I copied the code from another page where it works. The second javascript problem is: I have a site search form field at the top of every page and there is a javascript function called "check terms" in the head that is called from an event handler when the form is submitted. The purpose is to cause a javascript alert if someone submits the search with a blank search field. It doesn't work either and I get a javascript error that says checkterms is not defined when I look at the javascript console.

---------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html dir="<pun_content_direction>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<pun_char_encoding>">
<pun_head>
<SCRIPT LANGUAGE="JavaScript" type="text/html">
<!-- Begin

image1 = new Image();
image1.src = "../images/i05.gif";

image3 = new Image();
image3.src = "../images/i10.gif";

image4 = new Image();
image4.src = "../images/i12.gif";

image5 = new Image();
image5.src = "../images/i14.gif";

image6 = new Image();
image6.src = "../images/i17.gif";

image7 = new Image();
image7.src = "../images/i19.gif";

image8 = new Image();
image8.src = "../images/i22.gif";

image9 = new Image();
image9.src = "../images/i24.gif";

image10 = new Image();
image10.src = "../images/i28.gif";

image11 = new Image();
image11.src = "../images/i30.gif";

image12 = new Image();
image12.src = "../images/i32.gif";

image13 = new Image();
image13.src = "../images/i34.gif";

image14 = new Image();
image14.src = "../images/i36.gif";

image15 = new Image();
image15.src = "../images/i40.gif";

image16 = new Image();
image16.src = "../images/i42.gif";

// End -->
</SCRIPT>
<script language="Javascript">
<!--
if (window!= top)
top.location.href=location.href
//-->
</script>
<SCRIPT LANGUAGE="JavaScript" type="text/html">
<!--
function checkterms()
{
if (document.form_zqx.elements['sp-q'].value=='Search This Site') {
      alert('Please enter something to search for');   
    return false ;
      }
}
// -->
</script>
</head>
<body<pun_body> LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>

<TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=0>
    <TR>
        <TD COLSPAN=20 ROWSPAN=2>
            <IMG SRC="../images/cavejunction_01.jpg" WIDTH=426 HEIGHT=47></TD>
        <TD COLSPAN=2>
             </TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=37></TD>
    </TR>
    <TR>
        <TD COLSPAN=2 ROWSPAN=10>
            <IMG SRC="../images/cavejunction_03.jpg" WIDTH=324 HEIGHT=122 ALT="Cave Junction Oregon Community Information"></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=10></TD>
    </TR>
    <TR>
        <TD COLSPAN=16>
            <IMG SRC="../images/cavejunction_04.jpg" WIDTH=231 HEIGHT=14></TD>
        <TD COLSPAN=3>
            <a href="../"
                  onmouseover="image1.src='../images/i05.gif';"
                  onmouseout="image1.src='../images/cavejunction_05.gif';">
                  <img name="image1" src="../images/cavejunction_05.gif" border=0></a></TD>
        <TD ROWSPAN=9>
            <IMG SRC="../images/cavejunction_06.jpg" WIDTH=110 HEIGHT=112></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=14></TD>
    </TR>
    <TR>
        <TD COLSPAN=15>
            <IMG SRC="../images/cavejunction_07.jpg" WIDTH=202 HEIGHT=12></TD>
        <TD COLSPAN=4>           
                  <img name="image2" src="../images/cavejunction_08.gif" border=0></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=12></TD>
    </TR>
    <TR>
        <TD COLSPAN=14>
            <IMG SRC="../images/cavejunction_09.jpg" WIDTH=179 HEIGHT=15></TD>
        <TD COLSPAN=5>
            <a href="../cavejunction/history.shtml"
                  onmouseover="image3.src='../images/i10.gif';"
                  onmouseout="image3.src='../images/cavejunction_10.gif';">
                  <img name="image3" src="../images/cavejunction_10.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=15></TD>
    </TR>
    <TR>
        <TD COLSPAN=13>
            <IMG SRC="../images/cavejunction_11.jpg" WIDTH=158 HEIGHT=12></TD>
        <TD COLSPAN=6>
            <a href="../cj/businessdir.shtml"
                  onmouseover="image4.src='../images/i12.gif';"
                  onmouseout="image4.src='../images/cavejunction_12.gif';">
                  <img name="image4" src="../images/cavejunction_12.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=12></TD>
    </TR>
    <TR>
        <TD COLSPAN=12>
            <IMG SRC="../images/cavejunction_13.jpg" WIDTH=137 HEIGHT=16></TD>
        <TD COLSPAN=5>
            <a href="../cavejunction/pbook.shtml"
                  onmouseover="image5.src='../images/i14.gif';"
                  onmouseout="image5.src='../images/cavejunction_14.gif';">
                  <img name="image5" src="../images/cavejunction_14.gif" border=0></a></TD>
        <TD COLSPAN=2 ROWSPAN=5>
            <IMG SRC="../images/cavejunction_15.jpg" WIDTH=73 HEIGHT=59></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=16></TD>
    </TR>
    <TR>
        <TD COLSPAN=11>
            <IMG SRC="../images/cavejunction_16.jpg" WIDTH=119 HEIGHT=13></TD>
        <TD COLSPAN=6>
            <a href="../classified/class.shtml"
                  onmouseover="image6.src='../images/i17.gif';"
                  onmouseout="image6.src='../images/cavejunction_17.gif';">
                  <img name="image6" src="../images/cavejunction_17.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=13></TD>
    </TR>
    <TR>
        <TD COLSPAN=10>
            <IMG SRC="../images/cavejunction_18.jpg" WIDTH=103 HEIGHT=12></TD>
        <TD COLSPAN=4>
            <a href="../cgi-bin/guestbook/guestbook.cgi?type=view"
                  onmouseover="image7.src='../images/i19.gif';"
                  onmouseout="image7.src='../images/cavejunction_19.gif';">
                  <img name="image7" src="../images/cavejunction_19.gif" border=0></a></TD>
        <TD COLSPAN=3 ROWSPAN=12>
            <IMG SRC="../images/cavejunction_20.jpg" WIDTH=64 HEIGHT=137></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=12></TD>
    </TR>
    <TR>
        <TD COLSPAN=9>
            <IMG SRC="../images/cavejunction_21.jpg" WIDTH=90 HEIGHT=13></TD>
        <TD COLSPAN=5>
            <a href="../cavejunction/locsites.shtml"
                  onmouseover="image8.src='../images/i22.gif';"
                  onmouseout="image8.src='../images/cavejunction_22.gif';">
                  <img name="image8" src="../images/cavejunction_22.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=13></TD>
    </TR>
    <TR>
        <TD COLSPAN=8 ROWSPAN=2>
            <IMG SRC="../images/cavejunction_23.jpg" WIDTH=79 HEIGHT=12></TD>
        <TD COLSPAN=6 ROWSPAN=2>
            <a href="../cavejunction/cj-pics1.shtml"
                  onmouseover="image9.src='../images/i24.gif';"
                  onmouseout="image9.src='../images/cavejunction_24.gif';">
                  <img name="image9" src="../images/cavejunction_24.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=5></TD>
    </TR>
    <TR>
        <TD ROWSPAN=9>
            <IMG SRC="../images/cavejunction_25.jpg" WIDTH=30 HEIGHT=107></TD>
        <TD COLSPAN=4 ROWSPAN=6>
            <!--#exec cgi="/cgi-bin/banners/ads.cgi" --></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=7></TD>
    </TR>
    <TR>
        <TD COLSPAN=7>
            <IMG SRC="../images/cavejunction_27.jpg" WIDTH=66 HEIGHT=13></TD>
        <TD COLSPAN=7>
            <a href="../cavejunction/lodging.shtml"
                  onmouseover="image10.src='../images/i28.gif';"
                  onmouseout="image10.src='../images/cavejunction_28.gif';">
                  <img name="image10" src="../images/cavejunction_28.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=13></TD>
    </TR>
    <TR>
        <TD COLSPAN=6>
            <IMG SRC="../images/cavejunction_29.jpg" WIDTH=54 HEIGHT=13></TD>
        <TD COLSPAN=8>
            <a href="../cavejunction/map.shtml"
                  onmouseover="image11.src='../images/i30.gif';"
                  onmouseout="image11.src='../images/cavejunction_30.gif';">
                  <img name="image11" src="../images/cavejunction_30.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=13></TD>
    </TR>
    <TR>
        <TD COLSPAN=5>
            <IMG SRC="../images/cavejunction_31.jpg" WIDTH=45 HEIGHT=14></TD>
        <TD COLSPAN=9>
            <a href="../phpBB2/index.php"
                  onmouseover="image12.src='../images/i32.gif';"
                  onmouseout="image12.src='../images/cavejunction_32.gif';">
                  <img name="image12" src="../images/cavejunction_32.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=14></TD>
    </TR>
    <TR>
        <TD COLSPAN=4>                 
            <IMG SRC="../images/cavejunction_33.jpg" WIDTH=35 HEIGHT=13></TD>
        <TD COLSPAN=10>
                  <a href="../cavejunction/points.shtml"
                  onmouseover="image13.src='../images/i34.gif';"
                  onmouseout="image13.src='../images/cavejunction_34.gif';">           
                  <img name="image13" src="../images/cavejunction_34.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=13></TD>
    </TR>
    <TR>
        <TD COLSPAN=3 ROWSPAN=2>
            <IMG SRC="../images/cavejunction_35.jpg" WIDTH=26 HEIGHT=15></TD>
        <TD COLSPAN=11 ROWSPAN=2>
            <a href="../realestate/"
                  onmouseover="image14.src='../images/i36.gif';"
                  onmouseout="image14.src='../images/cavejunction_36.gif';">
                  <img name="image14" src="../images/cavejunction_36.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=9></TD>
    </TR>
    <TR>
        <TD COLSPAN=3 ROWSPAN=3>
            <IMG SRC="../images/cavejunction_37.jpg" WIDTH=262 HEIGHT=38></TD>
        <TD ROWSPAN=3>
            <!-- Atomz.com Search HTML for Cave Junction, Oregon -->
                  <form name="form_zqx" method="get" action="http://search.atomz.com/search/">                 
                    <input type=text size=20 maxsize=30 name="sp-q" value="Search This Site"
                  onFocus="if(this.value=='Search This Site')this.value='';"
                  onBlur="if(this.value=='')this.value='Search This Site';">
                  <input type=submit value=" Get " onClick="return checkterms()"><br>
                  <input type=hidden name="sp-a" value="00072c00-sp00000000">
                  </form></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=6></TD>
    </TR>
    <TR>
        <TD COLSPAN=2>
            <IMG SRC="../images/cavejunction_39.jpg" WIDTH=18 HEIGHT=14></TD>
        <TD COLSPAN=12>
            <a href="../cavejunction/outdoor.shtml"
                  onmouseover="image15.src='../images/i40.gif';"
                  onmouseout="image15.src='../images/cavejunction_40.gif';">
                  <img name="image15" src="../images/cavejunction_40.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=14></TD>
    </TR>
    <TR>
        <TD>
            <IMG SRC="../images/cavejunction_41.jpg" WIDTH=10 HEIGHT=18></TD>
        <TD COLSPAN=13>
            <a href="../cavejunction/bolan.shtml"
                  onmouseover="image16.src='../images/i42.gif';"
                  onmouseout="image16.src='../images/cavejunction_42.gif';">
                  <img name="image16" src="../images/cavejunction_42.gif" border=0></a></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=1 HEIGHT=18></TD>
    </TR>
    <TR>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=10 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=8 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=8 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=9 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=10 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=9 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=12 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=13 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=11 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=13 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=16 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=18 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=21 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=21 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=23 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=29 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=12 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=30 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=43 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=110 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=109 HEIGHT=1></TD>
        <TD>
            <IMG SRC="../images/spacer.gif" WIDTH=215 HEIGHT=1></TD>
        <TD></TD>
    </TR>
</TABLE>

<table width="100%">
<tr><td align="center">
<table width="97%">
<tr><td height="20"> </td></tr>
<tr><td align="left">
<table class="punmain" cellspacing="1" cellpadding="4">
    <tr class="punhead">
        <td class="punhead">
            <span class="puntitle"><pun_title></span><br>
            <pun_desc>
        </td>
    </tr>
    <tr>
        <td class="puncon1">
            <pun_navlinks><br><br>
            <pun_status>
        </td>
    </tr>
</table>

<pun_announcement>

<pun_main>

<pun_footer>
</td></tr></table>
</td></tr></table>

</body>
</html>

Re: JavaScript not working

link:
http://www.cavejunction.com/bboard/

Re: JavaScript not working

The link doesn't work.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: JavaScript not working

I gave up on it as it seems that for some reason javascript functions don't seem to be recognized when called by the event handlers. I copied all of the html source code right from the page and posted it . As you can see the javascript code syntax seems to be correct and it works on all other pages on the site. A perplexing problem. Javascript seems to work ok as long as there is no function call. I really like your program but gotta  have the javascript and that ain't happening.

Re: JavaScript not working

Well, since you removed it I guess that will have to be the case. It's hard to help when you can't see the thing in action.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8

Re: JavaScript not working

I tried looking at it last night but couldn't see anything wrong though it is always worth trying removing the doctype which for some unknown reason can screw up javascript.

What I did notice is that the javascript rollovers were unnecessary as exactly the same effect i.e. text changing colour could have been done with CSS just like PunBB.