码迷,mamicode.com
首页 > Windows程序 > 详细

window对象常用方法

时间:2016-04-21 20:31:44      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:

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

网页实例:请点我

window对象常用方法

标签:

原文地址:http://www.cnblogs.com/zxj95121/p/5418361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!