也不知道是不是那回事,好像出现死循环,所以用一个button,b2重新装载网页面了。
但是不好像不好控制红灯和绿灯在同一位置。我现在都糊涂了!<script language="javascript">
<!--
var pic = "";
var red,green;
function redlight()
{
if red=true then
点红灯; 载入red.jpg
pic += '<img src='image\red.jpg border="0">';
document.write(pic)
red=false;
green=true;
zidong();
}
function greenlight()
{
if green=true then
点绿灯;装入green.jpg
pic += '<img src='image\green.jpg border="0">';
document.write(pic)
 green=false;
red=true;
zidong();
}
fuction zidong()
{
if red=true then
  edlight(); 
else
  greenlight();
}
fuction light()
{
red=true;
zidong();
}
-->
</script>
....
<tr>
<td bgcolor="#FAF8ED"> 
<input type="button" name="b1" value="自动" onclick="light()"> 
<input type="button" name="b2" value="停止" onclick="javascript:load()"> 
</td>
</tr>
......

解决方案 »

  1.   

    好像是不行的
    我自己再写一个看看
    谢谢  xzq686(瞬)  ^_^
      

  2.   

    我是搞asp的,对javascript也不熟。哈!
    帮你UP
      

  3.   

    可惜,没有把第一个对象greenlighting清除。
    不知道判断一个量是不是对象的函数了
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    <!--
    function Showred()
    {
    document.all.redlight.style.backgroundColor="#FF0000";
    document.all.yellowlight.style.backgroundColor="#FFFFFF";
    document.all.greenlight.style.backgroundColor="#FFFFFF";
    redlighting=window.setInterval("Showyellow()",5000);
    }function Showyellow()
    {
    document.all.redlight.style.backgroundColor="#FFFFFF";
    document.all.yellowlight.style.backgroundColor="#FFFF00";
    document.all.greenlight.style.backgroundColor="#FFFFFF";
    yellowlighting=window.setInterval("Showgreen()",3000);
    clearInterval(redlighting);
    }function Showgreen()
    {
    document.all.redlight.style.backgroundColor="#FFFFFF";
    document.all.yellowlight.style.backgroundColor="#FFFFFF";
    document.all.greenlight.style.backgroundColor="#00FF00";
    greenlighting=window.setInterval("Showred()",4000);
    clearInterval(yellowlighting);
    }function Stop()
    {
    clearInterval(redlighting)
    clearInterval(yellowlighting)
    clearInterval(greenlighting)
    document.all.redlight.style.backgroundColor="#FFFFFF";
    document.all.yellowlight.style.backgroundColor="#FFFFFF";
    document.all.greenlight.style.backgroundColor="#FFFFFF";
    }//-->
    </script>
    </head><body bgcolor="#FFFFFF" text="#000000" leftmargin="300">
    <table width="169" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
      <tr> 
        <td id="redlight" bgcolor="#FFFFFF">&nbsp;</td>
        <td id="yellowlight" bgcolor="#FFFFFF">&nbsp;</td>
        <td id="greenlight" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
    </table>
    <br>
    <table width="169" border="0">
      <tr> 
        <td> 
          <div align="center">
            <input type="button" name="start" value="启动" onClick="Showred()">
          </div>
        </td>
        <td> 
          <div align="center">
            <input type="button" name="stop" value="恢复" onClick="Stop()">
          </div>
        </td>
      </tr>
    </table>
    </body>
    </html>
      

  4.   

    To:stefli(爱毅)和我的想法如出一辙
    谢谢你的热心帮助
    这样能实现一部分的功能了
    等我写出后我再把代码贴出来谢谢这里所有的人,i love here!
      

  5.   

    To:stefli(爱毅)和我的想法如出一辙
    谢谢你的热心帮助
    这样能实现一部分的功能了
    等我写出后我再把代码贴出来谢谢这里所有的人,i love here!