原来是在PHP里能好好的运行了,但是过了一会儿去执行了居然不会运行JS的函数了,我把这些函数放在<script></script>里有些函数会执行的,但是有些函数就不会执行了,不知这是什么原因,请高手给我指点一下,谢谢!!!!!!!!!!

解决方案 »

  1.   

    有些函数会执行的,但是有些函数就不会执行了?应该是js错误,请打开浏览器的js调试功能
      

  2.   

    <table border="0">
       <tr>
         <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(1);" onmouseout="this.style.backgroundColor='#33FFCC'"><span class="STYLE4">
                 学院动态  </span></td>
     <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(2);" onmouseout="this.style.backgroundColor='#33FFCC'">
         <span class="STYLE4">最近动态</span>  </td>
     <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(3);" onmouseout="this.style.backgroundColor='#33FFCC'">
         <span class="STYLE4">最近通知      </span></td>
     <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(4);" onmouseout="this.style.backgroundColor='#33FFCC'">
         <span class="STYLE4">新书推荐</span>
         </td>
          </tr>
    </table>
    <table border="0"  id="list1">
        <tr>
      <td>
       <div id="newspic" style="width:80px; height:110px">
       </div>
      </td>
      <td colspan="3">
        <table border="0" id="news">
     <?php
        mysql_query("set names gb2312");
        $data2="select * from news order by date desc limit 0,4";
    $result2=mysql_query($data2);
    while($row2=mysql_fetch_array($result2))
      {
     ?>
      <tr>
        <td>
     <a href="#" title="<?php echo $row2['title'];?>">
      <?php
        echo substr($row2["title"],0,16)."...";  
      ?>
      </a>
    </td>
        <td>
      <font color="#FF3300">
      <?php
        echo substr($row2["date"],0,16);  
      ?>
          </font>
    </td>
      </tr>
      <?php
           }
      ?>
      <td align="right" colspan="2">
        <a href="#">more>></a>
      </td>
    </table>
      </td>
    </tr>
      </table>
      <table border="0" style="display:none" id="list2">
       <?php
         mysql_query("set names gb2312");
         $data3="select * from newdt order by date desc limit 0,5";
     $select3=mysql_query($data3);
     while($row3=mysql_fetch_array($select3))
     {
       ?>
        <tr>
      <td>
        <a href="#">
     <?php
       echo substr($row3["title"],0,16)."...";
     ?>
        </a>
      </td>
      <td width="90px">&nbsp;</td>
      <td>
       <FONT color="#FF3300">
        <?php
       echo $row3["date"];
    ?>
    </FONT>
      </td>
    </tr>
    <?php }?>
    <tr>
      <td align="right" colspan="3">
        <a href="newdt.php">more>></a>
      </td>
    </tr>
      </table>
       <table border="0" style="display:none" id="list3">
         <tr>
       <td>
      asdfghjk
       </td>
     </tr>
       </table>
       <table border="0" style="display:none" id="list4">
          <tr>
         <?php 
          $data5="select * from newbook order by publishdate limit 0,1";
      $result5=mysql_query($data5);
      $row5=mysql_fetch_array($result5);
    ?>
         <td>
                <a href="#">
      <img src="<?php echo $row5['picture'];?>" style="width:80px; height:140px" alt="JAVA编程思想">
    </a>
     </td>
             <td>
       <table border="0">
           <tr>
    <td>
       书&nbsp;&nbsp;&nbsp;&nbsp;名:
       <?php
      echo $row5["bookname"]; 
       ?>
    </td>
     </tr>
     <tr>
       <td>
       作&nbsp;&nbsp;&nbsp;&nbsp;者:
       <?php
      echo $row5["author"]; 
       ?>
      </td>
     </tr>
         <tr>
      <td>
     出&nbsp;版&nbsp;社:
     <?php
     echo $row5["publisher"]; 
     ?>
      </td>
    </tr>
    <tr>
      <td>
     出版日期:
     <?php
     echo $row5["publishdate"]; 
     ?>
      </td>
    </tr>
    <tr>
      <td>
     简&nbsp;&nbsp;&nbsp;&nbsp;介:
     <?php
     echo substr($row5["jianjie"],0,20)."..."; 
     ?>
      </td>
    </tr>
    <tr>
      <td align="right">
        <a href="tsss.php?page=1">more>></a>
      </td>
    </tr>
     </table>
    这里是JS,check.js
    function check1(a){
      for(i=1;i<5;i++)
       {
       document.getElementById("list"+i).style.display="none";
       document.getElementById("list"+a).style.display="block";
       }
    }
    function check2(b){
      for(i=1;i<6;i++)
       {
       document.getElementById("menu"+i).style.display="none"
       }
    }function time(){
    var t=new Date();
    y=t.getYear();
    m=(t.getMonth()+1);
    d=t.getDate();
    var rq="北京时间:"+y+"年"+m+"月"+d+"日";
    setTimeout("time()",1000);
    document.all.time.innerText=rq;
    }

    var x=new Array(4);
    x[0]="好     好     学     习";
    x[1]="天     天     向     上";
    x[2]="图  书 馆  是  知  识  库";
    x[3]="欢  迎  光  临  学  习";
    var color=new Array();
    color[0]="yellow";
    color[1]="blue";
    color[2]="red";
    color[3]="gray";
    color[4]="green";
    var c=0;s=0;
    function display()
    {
    if(c<=4)
    {
         Layer1.innerText=x[s];
         document.all.Layer1.style.filter="glow(color="+color[c]+")";

         c++;
         timer=setTimeout("display()",500);
     }
         else
       {
         clearTimeout("timer");
     setTimeout("display2()",1000);
        }
    }
    function display2()
     {
     if(s<3)
       {
       s++;c=0;
       
           setTimeout("display()",300);
       }
       else
       {
       s=0;c=0;
           setTimeout("display()",300);
       } 
     }
     function open1()
     {
       window.open("zcusername.php","newframe","width=420,height=300,menubar=no,toolbar=no,scrollbar=no,location=no");
     }
     function display1(a)
        {
    for(i=1;i<3;i++)
        {
    document.getElementById("content"+i).style.display="none";
    document.getElementById("content"+a).style.display="block";
    }
    }
    function change()
    {
    document.getElementById("username").style.backgroundColor="blue";
    }
    function rechange()
    {
    document.getElementById("userpwd").style.backgroundColor="blue";
    }
    var picture=new Array();
    picture[0]="D:/phptest/pic/jiuye.jpg";
    picture[1]="D:/phptest/pic/ydh.jpg";
    picture[2]="D:/phptest/pic/jgfy.jpg";
    var i=0;
    function news()

        i=i%3;
    document.getElementById("newspic").innerHTML="<img width=80 height=110 src="+picture[i]+">";
    i++;
    setTimeout("news()",5000);
    }
    function gjsearch()
     { 
        a=document.getElementById("close").innerHTML;
      if(a=="打开")
    {
       document.getElementById("close").innerHTML="关闭";
       document.getElementById("list"+5).style.display="block";
    }的
       else
         {
       document.getElementById("close").innerHTML="打开";
       document.getElementById("list"+5).style.display="none";
     }
      }
    var img=new Array();
    img[0]="pic/donghu.jpg";
    img[1]="pic/guju.jpg";
    img[2]="pic/jinianguan.jpg";
    img[3]="pic/xianheng1.jpg";
    var j=0;k=0;
    var alt1=new Array();
    alt1[0]="绍兴东湖";
    alt1[1]="鲁迅故居";
    alt1[2]="鲁迅纪念馆";
    alt1[3]="绍兴咸享大酒店";
    function yulan()
     {
    j=j%4;k=k%4;
    document.getElementById("picture").innerHTML="<img alt='"+alt1[k]+"' width='385px' height='100px' src="+img[j]+" >";
    j++;k++;
    setTimeout("yulan()",5000); 
     }// JavaScript Document
      

  3.   

    <table border="0">
       <tr>
         <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(1);" onmouseout="this.style.backgroundColor='#33FFCC'"><span class="STYLE4">
                 学院动态  </span></td>
     <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(2);" onmouseout="this.style.backgroundColor='#33FFCC'">
         <span class="STYLE4">最近动态</span>  </td>
     <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(3);" onmouseout="this.style.backgroundColor='#33FFCC'">
         <span class="STYLE4">最近通知      </span></td>
     <td bgcolor="#33FFCC" onmouseover="this.style.backgroundColor='gray';check1(4);" onmouseout="this.style.backgroundColor='#33FFCC'">
         <span class="STYLE4">新书推荐</span>
         </td>
          </tr>
    </table>
    <table border="0"  id="list1">
        <tr>
      <td>
       <div id="newspic" style="width:80px; height:110px">
       </div>
      </td>
      <td colspan="3">
        <table border="0" id="news">
     <?php
        mysql_query("set names gb2312");
        $data2="select * from news order by date desc limit 0,4";
    $result2=mysql_query($data2);
    while($row2=mysql_fetch_array($result2))
      {
     ?>
      <tr>
        <td>
     <a href="#" title="<?php echo $row2['title'];?>">
      <?php
        echo substr($row2["title"],0,16)."...";  
      ?>
      </a>
    </td>
        <td>
      <font color="#FF3300">
      <?php
        echo substr($row2["date"],0,16);  
      ?>
          </font>
    </td>
      </tr>
      <?php
           }
      ?>
      <td align="right" colspan="2">
        <a href="#">more>></a>
      </td>
    </table>
      </td>
    </tr>
      </table>
      <table border="0" style="display:none" id="list2">
       <?php
         mysql_query("set names gb2312");
         $data3="select * from newdt order by date desc limit 0,5";
     $select3=mysql_query($data3);
     while($row3=mysql_fetch_array($select3))
     {
       ?>
        <tr>
      <td>
        <a href="#">
     <?php
       echo substr($row3["title"],0,16)."...";
     ?>
        </a>
      </td>
      <td width="90px">&nbsp;</td>
      <td>
       <FONT color="#FF3300">
        <?php
       echo $row3["date"];
    ?>
    </FONT>
      </td>
    </tr>
    <?php }?>
    <tr>
      <td align="right" colspan="3">
        <a href="newdt.php">more>></a>
      </td>
    </tr>
      </table>
       <table border="0" style="display:none" id="list3">
         <tr>
       <td>
      asdfghjk
       </td>
     </tr>
       </table>
       <table border="0" style="display:none" id="list4">
          <tr>
         <?php 
          $data5="select * from newbook order by publishdate limit 0,1";
      $result5=mysql_query($data5);
      $row5=mysql_fetch_array($result5);
    ?>
         <td>
                <a href="#">
      <img src="<?php echo $row5['picture'];?>" style="width:80px; height:140px" alt="JAVA编程思想">
    </a>
     </td>
             <td>
       <table border="0">
           <tr>
    <td>
       书&nbsp;&nbsp;&nbsp;&nbsp;名:
       <?php
      echo $row5["bookname"]; 
       ?>
    </td>
     </tr>
     <tr>
       <td>
       作&nbsp;&nbsp;&nbsp;&nbsp;者:
       <?php
      echo $row5["author"]; 
       ?>
      </td>
     </tr>
         <tr>
      <td>
     出&nbsp;版&nbsp;社:
     <?php
     echo $row5["publisher"]; 
     ?>
      </td>
    </tr>
    <tr>
      <td>
     出版日期:
     <?php
     echo $row5["publishdate"]; 
     ?>
      </td>
    </tr>
    <tr>
      <td>
     简&nbsp;&nbsp;&nbsp;&nbsp;介:
     <?php
     echo substr($row5["jianjie"],0,20)."..."; 
     ?>
      </td>
    </tr>
    <tr>
      <td align="right">
        <a href="tsss.php?page=1">more>></a>
      </td>
    </tr>
     </table>
    这里是JS,check.js
    function check1(a){
      for(i=1;i<5;i++)
       {
       document.getElementById("list"+i).style.display="none";
       document.getElementById("list"+a).style.display="block";
       }
    }
    function check2(b){
      for(i=1;i<6;i++)
       {
       document.getElementById("menu"+i).style.display="none"
       }
    }function time(){
    var t=new Date();
    y=t.getYear();
    m=(t.getMonth()+1);
    d=t.getDate();
    var rq="北京时间:"+y+"年"+m+"月"+d+"日";
    setTimeout("time()",1000);
    document.all.time.innerText=rq;
    }

    var x=new Array(4);
    x[0]="好     好     学     习";
    x[1]="天     天     向     上";
    x[2]="图  书 馆  是  知  识  库";
    x[3]="欢  迎  光  临  学  习";
    var color=new Array();
    color[0]="yellow";
    color[1]="blue";
    color[2]="red";
    color[3]="gray";
    color[4]="green";
    var c=0;s=0;
    function display()
    {
    if(c<=4)
    {
         Layer1.innerText=x[s];
         document.all.Layer1.style.filter="glow(color="+color[c]+")";

         c++;
         timer=setTimeout("display()",500);
     }
         else
       {
         clearTimeout("timer");
     setTimeout("display2()",1000);
        }
    }
    function display2()
     {
     if(s<3)
       {
       s++;c=0;
       
           setTimeout("display()",300);
       }
       else
       {
       s=0;c=0;
           setTimeout("display()",300);
       } 
     }
     function open1()
     {
       window.open("zcusername.php","newframe","width=420,height=300,menubar=no,toolbar=no,scrollbar=no,location=no");
     }
     function display1(a)
        {
    for(i=1;i<3;i++)
        {
    document.getElementById("content"+i).style.display="none";
    document.getElementById("content"+a).style.display="block";
    }
    }
    function change()
    {
    document.getElementById("username").style.backgroundColor="blue";
    }
    function rechange()
    {
    document.getElementById("userpwd").style.backgroundColor="blue";
    }
    var picture=new Array();
    picture[0]="D:/phptest/pic/jiuye.jpg";
    picture[1]="D:/phptest/pic/ydh.jpg";
    picture[2]="D:/phptest/pic/jgfy.jpg";
    var i=0;
    function news()

        i=i%3;
    document.getElementById("newspic").innerHTML="<img width=80 height=110 src="+picture[i]+">";
    i++;
    setTimeout("news()",5000);
    }
    function gjsearch()
     { 
        a=document.getElementById("close").innerHTML;
      if(a=="打开")
    {
       document.getElementById("close").innerHTML="关闭";
       document.getElementById("list"+5).style.display="block";
    }的
       else
         {
       document.getElementById("close").innerHTML="打开";
       document.getElementById("list"+5).style.display="none";
     }
      }
    var img=new Array();
    img[0]="pic/donghu.jpg";
    img[1]="pic/guju.jpg";
    img[2]="pic/jinianguan.jpg";
    img[3]="pic/xianheng1.jpg";
    var j=0;k=0;
    var alt1=new Array();
    alt1[0]="绍兴东湖";
    alt1[1]="鲁迅故居";
    alt1[2]="鲁迅纪念馆";
    alt1[3]="绍兴咸享大酒店";
    function yulan()
     {
    j=j%4;k=k%4;
    document.getElementById("picture").innerHTML="<img alt='"+alt1[k]+"' width='385px' height='100px' src="+img[j]+" >";
    j++;k++;
    setTimeout("yulan()",5000); 
     }// JavaScript Document
      

  4.   

    有可能是缓存问题。
    你试一下在php文件的最前面加上header("Cache-Control: no-cache, must-revalidate"); 
    header("Cache-Control: no-store");   
    header("Pragma: no-cache"); 
      

  5.   


    这里有个中文
    document.getElementById("close").innerHTML="关闭";
    document.getElementById("list"+5).style.display="block";
    }
      else
      {
    document.getElementById("close").innerHTML="打开";
    document.getElementById("list"+5).style.display="none";
    }去掉就可以了
      

  6.   


    这js,确实看得我眼挺晕了。
    楼主不能用一下jquery 么??? 
    帖代码的时候放到代码里去啊,例如
    function hello_word()
    {
     alert('hello world!');
    }