JavaScript 简单示例--窗口操作

窗口操作

1.test.html程序清单:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>窗口操作</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	
	<script type="text/javascript">
		var timer1, timer2;
		var num = 0;
		function click1() {
			alert("这是一个用alert方法弹出警告窗口示例!");
		}
		function click2() {
			if (confirm("你学会如何使用confirm窗口了吗?"));
			else
				alert("那就继续努力吧!");
		}
		function click3() {
			var a = 0;
			a = prompt("你喜欢哪个数字,1或者2?请在下面输入:", 1);
			document.myform.count.value=a;
		}
		function click4() {
			timer1 = setInterval("count1()", 1000);
		}
		function click5() {
			clearInterval(timer1);
		}
		function click6() {
			timer2 = setTimeout("count2()", 5000);
		}
		function count1() {
			num++;
			document.myform.count.value=num;
		}
		function count2() {
			open('fz.html', '', 'height=150, width=300');
		}
	</script>
  </head>
  
  <body>
    <center>
    	<h1>窗口操作</h1>
    	<hr/>
    	<form name="myform">
    		<input type="button" value="alert 窗口" onClick="click1();">
    		<input type="button" value="confirm 窗口" onClick="click2()">
    		<input type="button" value="prompt 窗口" onClick="click3()">
    		<hr/>
    		显示文本框:
    		<input type="text" name="count" size="10"/>
    		<hr/>
    		计时器1:
    		<input type="button" value="开始计时" onClick="click4()">
    		<input type="button" value="计时结束" onClick="click5()">
    		计时器2:
    		<input type="button" value="开始计时" onClick="click6()">
    	</form>
    </center>
  </body>
</html>

2.fz.html程序清单:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>辅助窗口</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
  
  <body οnclick="self.close()">
    <center>
    	<h2>计时结束</h2>
    	<hr/>
    	<h2>单击关闭页面</h2>
    </center>
  </body>
</html>

运行结果:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值