<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function haha1()
{
var now = new Date(); //获取系统日期,即Sun Apr 29 16:41:48 UTC+0800 2007
var yy = now.getYear(); //获取年,即2007
var mm = now.getMonth() + 1; //获取月,即04
var dd = now.getDay(); //获取该天的星期值
//获取时间
var hh = now.getHours(); //获取小时,即16
var mm = now.getMinutes(); //获取分钟,即41
var ss = now.getTime() % 60000; //获取时间,因为系统中时间是以毫秒计算的,
//所以秒要通过余60000得到。
ss = (ss - (ss % 1000)) / 1000; //然后,将得到的毫秒数再处理成秒
var clock = hh+':'; //将得到的各个部分连接成一个日期时间
if (mm < 10) clock += '0'; //字符串
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
document.all.testclock.value = clock;
}
</script>
<input type="text" name="testclock" > <script language="javascript" type="text/javascript">
haha1();
</script>
</html> 如果点击个按钮的话跳出当前时间下面的是可以的:
<html>
<script language="javascript" type="text/javascript">
function haha2()
{
var now = new Date(); //获取系统日期,即Sun Apr 29 16:41:48 UTC+0800 2007
var yy = now.getYear(); //获取年,即2007
var mm = now.getMonth() + 1; //获取月,即04
var dd = now.getDay(); //获取该天的星期值
//获取时间
var hh = now.getHours(); //获取小时,即16
var mm = now.getMinutes(); //获取分钟,即41
var ss = now.getTime() % 60000; //获取时间,因为系统中时间是以毫秒计算的,
//所以秒要通过余60000得到。
ss = (ss - (ss % 1000)) / 1000; //然后,将得到的毫秒数再处理成秒
var clock = hh+':'; //将得到的各个部分连接成一个日期时间
if (mm < 10) clock += '0'; //字符串
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
window.document.write(clock);
}
</script>
<input type="button" name="testclock" onclick="javascript:haha2();"><script language="javascript" type="text/javascript">
</script>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function haha1()
{
var now = new Date(); //获取系统日期,即Sun Apr 29 16:41:48 UTC+0800 2007
var yy = now.getYear(); //获取年,即2007
var mm = now.getMonth() + 1; //获取月,即04
var dd = now.getDay(); //获取该天的星期值
//获取时间
var hh = now.getHours(); //获取小时,即16
var mm = now.getMinutes(); //获取分钟,即41
var ss = now.getTime() % 60000; //获取时间,因为系统中时间是以毫秒计算的,
//所以秒要通过余60000得到。
ss = (ss - (ss % 1000)) / 1000; //然后,将得到的毫秒数再处理成秒
var clock = hh+':'; //将得到的各个部分连接成一个日期时间
if (mm < 10) clock += '0'; //字符串
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
document.all.testclock.value = clock;
}
</script>
<input type="text" name="testclock" > <script language="javascript" type="text/javascript">
haha1();
</script>
</html> 如果点击个按钮的话跳出当前时间下面的是可以的:
<html>
<script language="javascript" type="text/javascript">
function haha2()
{
var now = new Date(); //获取系统日期,即Sun Apr 29 16:41:48 UTC+0800 2007
var yy = now.getYear(); //获取年,即2007
var mm = now.getMonth() + 1; //获取月,即04
var dd = now.getDay(); //获取该天的星期值
//获取时间
var hh = now.getHours(); //获取小时,即16
var mm = now.getMinutes(); //获取分钟,即41
var ss = now.getTime() % 60000; //获取时间,因为系统中时间是以毫秒计算的,
//所以秒要通过余60000得到。
ss = (ss - (ss % 1000)) / 1000; //然后,将得到的毫秒数再处理成秒
var clock = hh+':'; //将得到的各个部分连接成一个日期时间
if (mm < 10) clock += '0'; //字符串
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
window.document.write(clock);
}
</script>
<input type="button" name="testclock" onclick="javascript:haha2();"><script language="javascript" type="text/javascript">
</script>
</html>
解决方案 »
- js操作文件
- currentStyle最终样式没有办法遍历吗??我想取得想里面的所有样式 类似cssText的功能
- 用免费jatoolsprinter免费版的打印iframe,没有任何反应,急,在线等!
- 又错了。郁闷呀。简单问题,我找不到错在那里大家帮,我谢了!
- 50分求教vb.net 关于javascript弹出对话框 问题!急~~~~~~~
- 在left帧中输入数据,想让mainFrame和bottomFrame同时更新,怎么不好用呢?请高手指点。
- 如何取字符串中的字符?
- 继续刚才的问题
- 还是showModelessDialog的问题
- 用asp 或 javascrpt 怎麼打開 autocad 的圖???
- 为什么是undefined呢?
- DIV移动到另一DIV区域内,前DIV隐藏并弹出提示
呵呵,没什么,可能是口头语吧!