设置新开窗口的特征-在状态栏中显示时间

设置新开窗口特征

<html>
<head>
<title>设置新开窗口的特征</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<body>
<!--新开一个指定大小的窗口-->
<input type="button" οnclick="window.open('sample01.htm','窗口名字','width=300,height=100')" value="按钮一">
<!--新开一个指定大小的窗口,并显示地址栏-->
<input type="button" οnclick="window.open('sample01.htm','','width=300,height=100,location=yes')" value="按钮二">
<!--新开一个指定大小的窗口,并显示地址栏、菜单栏-->
<input type="button" οnclick="window.open('sample01.htm','','width=300,height=100,location=yes,menubar=yes')" value="按钮三">
<!--新开一个窗口,并显示地址栏、菜单栏、可以调整窗口大小-->
<input type="button" οnclick="window.open('sample01.htm','','location=yes,menubar=yes,resizable=yes')" value="按钮四">
</body>
</html>

周期执行-在状态栏中显示时间

<html>
<head>
<title>在状态栏显示时间</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script type="text/javascript" language="javascript">
<!--
function showTime()
{
//获得当前时间
var now = new Date();
//在状态栏中显示当前时间
window.status = "当前时间为:" + now.toLocaleString();
}
//每隔1移调用一次showTime()函数
window.setInterval("showTime()",1000);
-->
</script>
</head>
<body>
</body>
</html>

延迟执行--跑马灯

<html>
<head>
<title>跑马灯</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script type="text/javascript" language="javascript">
<!--
//设置跑马灯内容
var str = "您好,欢迎光临!";

//设置一个用于控制显示字数的变量
strLeng = 0;

//设置跑马灯的函数
function showText()
{
//如果要显示的字数等于跑马灯内容的长度,则将其重新初始化
if (strLeng==str.length)
{
strLeng = 0;
}
//显示字数加1
strLeng++;

//显示在状态栏的文字
var statusText = str.substring(0,strLeng);
window.status = statusText;
//延时1秒钟之后再一次调用本函数
window.setTimeout("showText()",1000);
}
-->
</script>
</head>
<body οnlοad="showText()">
</body>
</html>

取消周期执行--延时注册
<html>
<head>
<title>延时注册</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script type="text/javascript" language="javascript">
<!--
//设置倒计时的时间
var time = 10;

//在按钮上显示倒计时的时间
function disabledButton()
{
time--;
myForm.myButton.value = "请阅读(" + time + ")";
}
//每隔1移调用一次showTime()函数
var runId = window.setInterval("disabledButton()",1000);

//结果在按钮上显示倒计时的时间
function enableButton()
{
//停止周期执行
window.clearTimeout(runId);
//将按钮设为可用
myForm.myButton.disabled = false;
//修改按钮上的文字
window.setTimeout("myForm.myButton.value='注册'",1000);
}

//10秒后停止周期执行
window.setTimeout("enableButton()",10000);
-->
</script>
</head>
<body>
<form name="myForm">
<p align="center">注册条款</p>
<p>要善于网上学习,不浏览不良信息;要诚实友好交流,不侮辱欺诈他人;要增强自护意识,不随意约会网友;要维护网络安全,不破坏网络秩序;要有益身心健康,不沉溺虚拟时空。</p>
<p align="center"><input type="button" name="myButton" value="请阅读(10)" disabled="true" οnclick="alert('进入注册页面')"></p>
</form>
</body>
</html>

取消延时执行--计数器
<html>
<head>
<title>计时器</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script type="text/javascript" language="javascript">
<!--
//定义变量,该变量用于存储setTimeout()方法的返回值
var timeoutId;

//开始计数
function countBegin()
{
//将文本框中的数字加1后显示在文本框中
myForm.myText.value = parseInt(myForm.myText.value)+1;
//延时0.1秒后再将执行该函数
timeoutId = window.setTimeout("countBegin()",100);
}

//停止计数
function countEnd()
{
window.clearTimeout(timeoutId);
}
-->
</script>
</head>
<body>
<form name="myForm">
计时:<input type="text" size="5" value="0" name="myText"><br>
<input type="button" value="开始计时" οnclick="countBegin()">
<input type="button" value="停止计时" οnclick="countEnd()">
</form>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值