⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4daojishi.htm

📁 JavaScript实例
💻 HTM
字号:
<html>
<head>
<title>洪恩在线 - Javascript实例</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../homepage.css">
</head>

<body bgcolor="#FFFFFF" ><script language="Javascript" src="/pub/js/head.js"></script>
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr bgcolor="CFDFFF"> 
    <td height=20 class="p1" align="left"><img src="/pc/img/blank.gif" width="12" height="8"><font color="#000000"><font color="#FF9966">当前位置</font>:<a href="/default.htm" class="under">洪恩在线</a> 
      -&gt; <a href="/pc/index.htm" class="under">电脑乐园</a> -&gt; JavaScript实例</font></td>
  </tr>
</table>
<table width="760" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="207" valign="top"><img src="img/bule.gif" width="207" height="13"></td>
    <td bgcolor="A8A8AB" width="1"><img src="img/blank.gif" width="1" height="1"></td>
    <td align="right" height="22" width=530><img src="img/js.gif" width="186" height="20"></td>
    <td width="22"><img src="img/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="124"><img src="img/blank.gif" width="1" height="1"></td>
    <td background="img/line.gif" height="27" width=636><img src="img/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class=p3 align="center" width=711><b>     倒 计 时</b></td>
    <td class="p2" width="1" bgcolor="A8A8AB"><img src="img/blank.gif" width="1" height="1"></td>
    <td class="p2" width="48">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td align="center" valign="top">&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="5F74BF" width="28" align="center"><img src="img/bule1.gif" width="28" height="49"></td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">效 果 演 示</font></b><font color="#FFFFFF">:</font></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="271">
        <tr align="center"> 
          <td height="145" width="47">&nbsp; </td>
          <td background="img/daojishi.jpg" height="145" width="258" valign="top"> 
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <br>
            <script language="JavaScript">
<!-- // 
var deadline= new Date("7/30/2000");
var  symbol="7月30日";
var now = new Date();
var leave =deadline.getTime() - now.getTime();
var day = Math.floor(leave / (1000 * 60 * 60 * 24));
if (day > 0)
   document.write("今天离"+ symbol+"还有"+day +"天")
else if (day == 0)
     document.write("只有1天啦!")
else
    document.write("唉呀!已经过了!");
// -->
</script>
          </td>
          <td height="145" width="152">&nbsp;</td>
        </tr>
      </table>
      <p>&nbsp;</p>
      </td>
    <td bgcolor="5F74BF" width="28" align="center">&nbsp;</td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="30">&nbsp;</td>
        </tr>
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">源代码如下</font></b><font color="#FFFFFF">:</font></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="457" class="p2" valign="top"><b><br>
      <br>
      </b><span class="p1"><font color="#6633FF"><br>
      这段程序放在&lt;body&gt;与&lt;/body&gt;之间</font></span><b><br>
      </b>
      <form>
        <p> 
          <textarea name="textarea" onFocus="this.select()" onMouseOver="this.focus()" cols="50" rows="10" wrap="VIRTUAL" style="BACKGROUND-COLOR: #D5E9FD;" >&lt;script language=&quot;JavaScript&quot;&gt;
&lt;!-- // 
var deadline= new Date(&quot;7/30/2000&quot;);
var  symbol=&quot;7月30日&quot;;
var now = new Date();
var leave =deadline.getTime() - now.getTime();
var day = Math.floor(leave / (1000 * 60 * 60 * 24));
if (day &gt; 0)
   document.write(&quot;今天离&quot;+ symbol+&quot;还有&quot;+day +&quot;天&quot;)
else if (day == 0)
     document.write(&quot;只有1天啦!&quot;)
else
    document.write(&quot;唉呀!已经过了!&quot;);
// --&gt;
&lt;/script&gt;</textarea>
          </p>
        <p>&nbsp;</p>
        </form>
      <b><br>
      </b></td>
    <td bgcolor="5F74BF" width="28" align="center">&nbsp;</td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="bottom"> 
      <table width="238" border="0" cellspacing="0" cellpadding="0">
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">源程序讲解:</font></b></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="457" class="p2" valign="top">&nbsp;</td>
    <td bgcolor="5F74BF" width="28" align="center"><img src="img/bule1.gif" width="28" height="49"></td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class="p2" align="right" width="693"> <br>
      <table width="650" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td> 
            <table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolorlight="#666666" bordercolordark="#666666" class=p2>
              <tr> 
                <td width="409">var deadline= new Date("7/30/2000");<br>
                </td>
                <td width="351">定义“到期”变量。你可以随便设置。</td>
              </tr>
              <tr> 
                <td width="409" bgcolor="CFDFFF">var symbol="7月30日"; <br>
                </td>
                <td width="351" bgcolor="CFDFFF">定义“日期性质”变量,可以随便设置。</td>
              </tr>
              <tr> 
                <td width="409">var now = new Date(); <br>
                </td>
                <td width="351">设置“现在”的时间。</td>
              </tr>
              <tr> 
                <td width="409" bgcolor="CFDFFF">var leave =deadline.getTime() 
                  - now.getTime();<br>
                </td>
                <td width="351" bgcolor="CFDFFF">设置变量“leave”的值为到期时间减现在时间,返回的为毫秒数。</td>
              </tr>
              <tr> 
                <td width="409">var day = Math.floor(leave / (1000 * 60 * 60 * 
                  24));<br>
                  ;</td>
                <td width="351">将毫秒数化为天数,并返回一个不大于天数的整数。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="409">if (day > 0) <br>
                  document.write("今天离"+ symbol+"还有"+day +"天")<br>
                  )</td>
                <td width="351">如果日期不是今天到期,就输出“还有多少天”。</td>
              </tr>
              <tr> 
                <td width="409">else if (day == 0)<br>
                  document.write("只有1天啦!")<br>
                </td>
                <td width="351">如果到期日就是机器今天的系统日期,则输出“只有一天了”。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="409">else<br>
                  document.write("唉呀!已经过了!")</td>
                <td width="351">否则,就是过期了。</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <br>
      <br>
    </td>
    <td class="p2" width="18">&nbsp;</td>
    <td class="p2" width="1" bgcolor="A8A8AB"><img src="img/blank.gif" width="1" height="1"></td>
    <td class="p2" width="48">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr bgcolor="5F74BF"> 
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -