于于.NET

<< 创建DataGrid的个性化页导航栏 | 首页 | DataList外观 >> 2004-02-18 用JavaScript编写当天日期 Tag: JavaScript 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及 本声明 http://njyy.blogbus.com/logs/93034.html 在.NET中适当的调用或者写入JavaScript脚本,会起到一些意想不到的效果 方法一: <table cellpadding="0" cellspacing="0" width="100%" border="1px" bordercolor="lightblue" style="BORDER-COLLAPSE: collapse"> <tr> <td> 今天是 <script language="JavaScript"> <!--- today=new Date(); var hours = today.getHours(); var minutes = today.getMinutes(); var seconds = today.getSeconds(); var timeValue = "" + ((hours >12) ? hours -12 :hours); timeValue += ((minutes < 10) ? "<BLINK>:</BLINK>0" : "<BLINK>:</BLINK>") + minutes+""; timeValue += (hours >= 12) ? "PM" : "AM"; function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i] } var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("",today.getYear(),"年","",today.getMonth()+1,"月","",today.getDate(),"日 ",d[today.getDay()+1]," "); //--> </script> </td> </tr> </table> 方法二: 为了使HTML中的代码更加简洁和方便以后的维护,推荐你采用下面的方法: <table cellpadding="0" cellspacing="0" width="100%" border="1px" bordercolor="lightblue" style="BORDER-COLLAPSE: collapse"> <tr> <td> 今天是<script language="javascript" src="TodayDate.js"> </script> </td> </tr> </table> 其中的TodayDate.js中的内容为: today=new Date(); var hours = today.getHours(); var minutes = today.getMinutes(); var seconds = today.getSeconds(); var timeValue = "" + ((hours >12) ? hours -12 :hours); timeValue += ((minutes < 10) ? "<BLINK>:</BLINK>0" : "<BLINK>:</BLINK>") + minutes+""; timeValue += (hours >= 12) ? "PM" : "AM"; function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i] } var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("",today.getYear(),"年","",today.getMonth()+1,"月","",today.getDate(),"日 ",d[today.getDay()+1]," "); 当做好后运行,发现用方法二的做法界面上出现的是乱码,你可以会问这是这么回事,需要怎么修改呢?其实这要在Web.config设置中将encoding="utf-8" 修改为encoding="gb2312"就ok啦!修改完后你会看到和方法一效果相同的界面。 随机文章: 这回是真的搬家了 2008-03-28 DataGrid使用-配色方案 2004-02-24 asp.net常用的javascript经典例子(一) 2004-02-19 DataList外观 2004-02-19 创建DataGrid的个性化页导航栏 2004-02-17 收藏到: Del.icio.us 引用地址: pairs 发表于 09:22 | 编辑 | 继续话题 | 转发 | 推荐 发表评论

原始快照:web.archive.org