window对象常用方法

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window对象方法</title>
<script>
window.onload=function(){
//打开一个新的窗口,并赋值给一个变量
subWindow=window.open("http://www.baidu.com","name","height=200,width=300");//我在前面没有加var,他变成了全局变量。
setTimeout('location()',1800);
setTimeout('CloseW();',4000);//定时,2秒后,执行CloseW函数
}
function CloseW(){
subWindow.close();
//alert()方法也是window对象的方法,只不过window可以省略不写
window.alert('弹出一个提示框');
var bool=window.confirm('您确定要删除该条数据么?');//confirm方法,用户点击是放回ture,点击取消返回false。
if(bool)
alert('您的数据删除成功!');
else
alert('您已取消删除数据!');
//实现页面跳转
var answer=window.prompt("你在哪里读书",'ahnu');//返回null或用户输入的字符串值(非空)
if(answer)
alert(answer);
else
alert('您输入的字符串为空'); }
function location(){
subWindow.location.href="http://www.anshida.net";
}
</script>
</head>
<body>
<span id="e">hehe</span>
</body>
</html>

网页实例:请点我

上一篇:layui在open弹出层回显,解决动态select数据回显问题


下一篇:spring cloud 学习研究- spring-cloud-microservice-example