JavaScript中的Window

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>JavaScript中的Window</title>
		<!--Window学习
		1.Window常用的方法
		  对话框
		    alert---弹出警告框(弹出的窗口只能点确定)
			confirm----确认框(弹出的窗口既可以点确定,也可以点取消),点确定会返回true,点取消会返回false
			prompt---prompt("描述内容"):弹出一个输入框,并可以获取输入结果
		延时函数
			setTimeout("执行动作",毫秒数)----延误指定的毫秒数,然后执行指定的动作,执行动作可以是另外的方法,也可以是匿名的方法,注意必须加引号
			clearTimeOut---清除指定的延时函数	
			setInterval("执行动作",毫秒数)---每隔多少秒都会执行一次这个函数
			
			
		子窗口
		  window.open("open.html","win","width=100,heigth=200")
		2.location
		
		3.history
		
			
			
		-->
		<script type="text/javascript">
			var ids;
			function testAlert(){
				alert("测试alert");
			}
			function testConfirm(){
				var testC=confirm("测试confirm");
				alert(testC);//点确定会返回true,点取消会返回false,
			}
			function testPrompt(){
				var tetsp=prompt("请输入一个值");
				alert(tetsp);
			}
			function testTimeout1(){
				setTimeout("alert('直接使用alert')",2000);
			}
			function testTimeout(){
				setTimeout("testTimeoutFunction()",3000);//调用另外的方法
			}
			function testTimeoutFunction(){
				alert("掉用方法");
			}
			function testTimeout2(){
				ids=setTimeout(function(){
					alert("匿名方法");
					},1000);
			}
			function testClearTimeOut(){
				clearTimeout(ids);
			}
			
			function testSetInterval(){
				setInterval(function(){
					alert("延时函数");
				},1000);
			}	
			function testWindow(){
				 window.open("son.html","win","width=20,heigth=10,top=100,left=100");
			}
			
			
		</script>
	</head>
	<body>
	 <input type="button" value="测试alert" onclick="testAlert()" />	
	 <input type="button" value="测试confirm" onclick="testConfirm()" />
	 <input type="button" value="测试prompt" onclick="testPrompt()" />
	 <hr />
	 <input type="button" value="测试setTimeout1" onclick="testTimeout1()" />
	 <input type="button" value="测试setTimeout" onclick="testTimeout()" />
	 <input type="button" value="测试setTimeout2" onclick="testTimeout2()" />
	 <hr />
	 <input type="button" value="测试ClearTimeOut" onclick="testClearTimeOut()" />
	 <hr />
	 <input type="button" value="测试setInterval" onclick="testSetInterval()" />
	 <hr />
	 <input type="button" value="测试子窗口" onclick="testWindow()" />
	 
	</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值