您的位置:首页 > 运维架构

window对象的open和close方法

2014-11-27 15:25 453 查看




实现一个窗口打开另一个窗口,五秒钟自动关闭的功能;

源网页为:

<html>
<head>
<script type="text/javascript">

window.open("time.html","","width=400,height=100");

</script>
</head>

<body></body>
</html>
打开网页为:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=gbk"/>
<title>计时方法用法</title>
<style type="text/css">
#time{width:180px;height:40px;background:#fac;margin:0 auto;font-size:11pt;padding-left:5px;padding-top:10px;color:gray;line-height:20px}
</style>
<script type="text/javascript">
	//setTimeout(update_time,1000);
	//setInterval(update_time,1000);
	var id ;
	function init(){
		id = setInterval(update_time,1000);
		<span style="color:#ff0000;">setTimeout("self.close()",5000);//self.colse()方法</span>
	}
	
	function update_time(){
		var date = new Date();
		var time = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
		document.getElementById('time').innerText = time;
	}
	
	function stop(){
		clearInterval(id);
	}
</script>
</head>
<body onload="init()">
	<div id='time'>
	</div>
	<input type="button" value="stop" onclick="stop()"/>
</body>

</html>



此页面五秒后会自动关闭

怎么实现向打开的页面中输入内容?

<html>
<head>
<script type="text/javascript">
var win=window.open("time.html","","width=400,height=100");
win.document.write("您好!<span style="font-family: Arial, Helvetica, sans-serif;">"/></span>
<span style="font-family: Arial, Helvetica, sans-serif;">");</span>
</script>
</head>

<body></body>
</html>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐