网页状态栏有时间,怎样用DW制作 5
我们要考试了,老师给我们的题目是用DW制作动态网页,网页的状态栏要有时间,麻烦各位告诉我怎么搞咯!我下个星期就要考试了。谢谢大家...
我们要考试了,老师给我们的题目是用DW制作动态网页,网页的状态栏要有时间,麻烦各位告诉我怎么搞咯!我下个星期就要考试了。谢谢大家
展开
1个回答
展开全部
你要的是在状态栏里显示当前时间吗?
你把下面的复制到<body></body>之间即可(另附你一个显示停留时间的例子,可不要两个复制在一起了。)
显示当前时间:
<BODY onLoad="run(); timerONE=window.setTimeout"></BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
timeID = null;
timeRunning = false;
function stop () {
if(timeRunning)
clearTimeout(timeID);
timeRunning = false;
}
function time () {
tick = new Date();
hours = tick.getHours();
minutes = tick.getMinutes();
seconds = tick.getSeconds();
day = tick.getDay();
month = tick.getMonth();
date = tick.getDate();
year = tick.getYear();
current = "" + ((hours >12) ? hours -12 :hours)
current += ((minutes < 10) ? ":0" : ":") + minutes
current += ((seconds < 10) ? ":0" : ":") + seconds
current += (hours >= 12) ? " P.M." : " A.M."
if(day==0){var weekday = " 星期日"}
if(day==1){var weekday = " 星期一"}
if(day==2){var weekday = " 星期二"}
if(day==3){var weekday = " 星期三"}
if(day==4){var weekday = " 星期四"}
if(day==5){var weekday = " 星期五"}
if(day==6){var weekday = " 星期六"}
current +=(weekday)
window.status=current;
timeID = setTimeout("time()",1000);
timeRunning = true;
}
function run(){
stop();
time();
}
//-->
</SCRIPT>
--------------------------------------
显示你的在线时间
<!--在你的HTML文件的<head>和</head>之间加上以下代码:-->
<script language="javascript">
var Temp;
var TimerId = null;
var TimerRunning = false;
Seconds = 0
Minutes = 0
Hours = 0
function showtime()
{
if(Seconds >= 59)
{
Seconds = 0
if(Minutes >= 59)
{
Minutes = 0
if(Hours >= 23)
{
Seconds = 0
Minutes = 0
Hours = 0
}
else {
++Hours
}
}
else {
++Minutes
}
}
else {
++Seconds
}
if(Seconds != 1) { var ss="s" } else { var ss="" }
if(Minutes != 1) { var ms="s" } else { var ms="" }
if(Hours != 1) { var hs="s" } else { var hs="" }
Temp = '你在本页停留了 '+Hours+' 小时'+', '+Minutes+' 分'+', '+Seconds+' 秒'+''
window.status = Temp;
TimerId = setTimeout("showtime()", 1000);
TimerRunning = true;
}
var TimerId = null;
var TimerRunning = false;
function stopClock() {
if(TimerRunning)
clearTimeout(TimerId);
TimerRunning = false;
}
function startClock() {
stopClock();
showtime();
}
function stat(txt) {
window.status = txt;
setTimeout("erase()", 2000);
}
function erase() {
window.status = "";
}
</script>
<body onLoad="startClock()">
你把下面的复制到<body></body>之间即可(另附你一个显示停留时间的例子,可不要两个复制在一起了。)
显示当前时间:
<BODY onLoad="run(); timerONE=window.setTimeout"></BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
timeID = null;
timeRunning = false;
function stop () {
if(timeRunning)
clearTimeout(timeID);
timeRunning = false;
}
function time () {
tick = new Date();
hours = tick.getHours();
minutes = tick.getMinutes();
seconds = tick.getSeconds();
day = tick.getDay();
month = tick.getMonth();
date = tick.getDate();
year = tick.getYear();
current = "" + ((hours >12) ? hours -12 :hours)
current += ((minutes < 10) ? ":0" : ":") + minutes
current += ((seconds < 10) ? ":0" : ":") + seconds
current += (hours >= 12) ? " P.M." : " A.M."
if(day==0){var weekday = " 星期日"}
if(day==1){var weekday = " 星期一"}
if(day==2){var weekday = " 星期二"}
if(day==3){var weekday = " 星期三"}
if(day==4){var weekday = " 星期四"}
if(day==5){var weekday = " 星期五"}
if(day==6){var weekday = " 星期六"}
current +=(weekday)
window.status=current;
timeID = setTimeout("time()",1000);
timeRunning = true;
}
function run(){
stop();
time();
}
//-->
</SCRIPT>
--------------------------------------
显示你的在线时间
<!--在你的HTML文件的<head>和</head>之间加上以下代码:-->
<script language="javascript">
var Temp;
var TimerId = null;
var TimerRunning = false;
Seconds = 0
Minutes = 0
Hours = 0
function showtime()
{
if(Seconds >= 59)
{
Seconds = 0
if(Minutes >= 59)
{
Minutes = 0
if(Hours >= 23)
{
Seconds = 0
Minutes = 0
Hours = 0
}
else {
++Hours
}
}
else {
++Minutes
}
}
else {
++Seconds
}
if(Seconds != 1) { var ss="s" } else { var ss="" }
if(Minutes != 1) { var ms="s" } else { var ms="" }
if(Hours != 1) { var hs="s" } else { var hs="" }
Temp = '你在本页停留了 '+Hours+' 小时'+', '+Minutes+' 分'+', '+Seconds+' 秒'+''
window.status = Temp;
TimerId = setTimeout("showtime()", 1000);
TimerRunning = true;
}
var TimerId = null;
var TimerRunning = false;
function stopClock() {
if(TimerRunning)
clearTimeout(TimerId);
TimerRunning = false;
}
function startClock() {
stopClock();
showtime();
}
function stat(txt) {
window.status = txt;
setTimeout("erase()", 2000);
}
function erase() {
window.status = "";
}
</script>
<body onLoad="startClock()">
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询