DHTML_____window对象方法
生活随笔
收集整理的這篇文章主要介紹了
DHTML_____window对象方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<html>
<head><meta charset="utf-8"><title>window對象方法</title>
</head><body>
<div style="text-align:center;text-">Window對象的方法</div>
<div id="divId"></div>
<input type="button" value="取消間歇定時器" onclick="clearInter()"/><input type="button" value="打開新窗口" onclick="moveWin()"/><input type="button" value="改變瀏覽器窗口大小" onclick="resizeWin()"/><input type="button" value="打開新窗口" onclick="openWin()"/><input type="button" value="新窗口自動關閉" onclick="testWin()"/><input type="button" value="模態對話框自動關閉" onclick="testDialog()"/><script language="javascript">
//01alert
//window.alert("alert!!!");//02 確認對話框
//window.confirm("???");//03 輸入信息對話框
//window.prompt("提示信息","默認值");//04 close() 關閉當前瀏覽器窗口
//window.close();//05 導航到指定URL資源
//window.navigate("http://www.baidu.com");
//window.navigate('http://www.baidu.com');//06 間歇定時器
var int=setInterval("inner()",2000);
var s="";
function inner(){var div=document.getElementById("divId");s+="Hello World!!!<br/>";div.innerHTML=s;
}//07 定時計時器
//setTimeout('inner()',5000);//08 取消間歇定時器
//即使得當前間歇計時器停止執行,執行過的內容仍在
function clearInter(){window.clearInterval(int);
}//09 取消定時計時器 參數為計時器變量
//window.clearTimeout(int);//10 移動瀏覽器窗口到指定的屏幕位置
//在IE瀏覽器中有效
function moveWin(){myWin=window.open('http://www.baidu.com','_blank','width=200,height=100');myWin.document.write("新窗口!!!");myWin.moveTo(0,0);myWin.focus();
}//11 改變瀏覽器窗口大小
function resizeWin(){window.resizeTo(400,400);
}//12 打開新窗口
function openWin(){window.open('http://www.baidu.com','_blank','top=10,left=0,toolbar=no,width=100,height=100');
}//13 模態對話框窗口 必須關閉模態對話框才能在原始網頁窗口進行操作
//window.showModalDialog('http://www.baidu.com','zhangsan');//14 非模態對話框窗口 不用關閉模態對話框也能在原始網頁窗口進行操作
//window.showModelessDialog('http://www.baidu.com','zhangsan');//測試打開一個小窗口 5秒后自動關閉
function testWin(){myWin=window.open("./test02.html","_blank","width=100,height=100");myWin.moveTo(0,0);setTimeout("myWin.close()",5000);
}function testDialog(){var myDialog=window.showModalDialog();setTimeout('myDialog.close()',5000);//
}
</script>
</body>
</html> View Code 1 <html>
2 <head>
3 <meta charset="utf-8">
4 <title>window對象方法</title>
5 </head>
6
7 <body>
8 <div style="text-align:center;text-">Window對象的方法</div>
9 <div id="divId"></div>
10 <input type="button" value="取消間歇定時器" onclick="clearInter()"/>
11
12 <input type="button" value="打開新窗口" onclick="moveWin()"/>
13
14 <input type="button" value="改變瀏覽器窗口大小" onclick="resizeWin()"/>
15
16 <input type="button" value="打開新窗口" onclick="openWin()"/>
17
18 <input type="button" value="新窗口自動關閉" onclick="testWin()"/>
19
20 <input type="button" value="模態對話框自動關閉" onclick="testDialog()"/>
21
22 <script language="javascript">
23 //01alert
24 //window.alert("alert!!!");
25
26 //02 確認對話框
27 //window.confirm("???");
28
29 //03 輸入信息對話框
30 //window.prompt("提示信息","默認值");
31
32 //04 close() 關閉當前瀏覽器窗口
33 //window.close();
34
35 //05 導航到指定URL資源
36 //window.navigate("http://www.baidu.com");
37 //window.navigate('http://www.baidu.com');
38
39 //06 間歇定時器
40 var int=setInterval("inner()",2000);
41 var s="";
42 function inner(){
43 var div=document.getElementById("divId");
44 s+="Hello World!!!<br/>";
45 div.innerHTML=s;
46 }
47
48 //07 定時計時器
49 //setTimeout('inner()',5000);
50
51 //08 取消間歇定時器
52 //即使得當前間歇計時器停止執行,執行過的內容仍在
53 function clearInter(){
54 window.clearInterval(int);
55 }
56
57 //09 取消定時計時器 參數為計時器變量
58 //window.clearTimeout(int);
59
60 //10 移動瀏覽器窗口到指定的屏幕位置
61 //在IE瀏覽器中有效
62 function moveWin(){
63 myWin=window.open('http://www.baidu.com','_blank','width=200,height=100');
64 myWin.document.write("新窗口!!!");
65 myWin.moveTo(0,0);
66 myWin.focus();
67 }
68
69 //11 改變瀏覽器窗口大小
70 function resizeWin(){
71 window.resizeTo(400,400);
72 }
73
74 //12 打開新窗口
75 function openWin(){
76 window.open('http://www.baidu.com','_blank','top=10,left=0,toolbar=no,width=100,height=100');
77 }
78
79 //13 模態對話框窗口 必須關閉模態對話框才能在原始網頁窗口進行操作
80 //window.showModalDialog('http://www.baidu.com','zhangsan');
81
82 //14 非模態對話框窗口 不用關閉模態對話框也能在原始網頁窗口進行操作
83 //window.showModelessDialog('http://www.baidu.com','zhangsan');
84
85 //測試打開一個小窗口 5秒后自動關閉
86 function testWin(){
87 myWin=window.open("./test02.html","_blank","width=100,height=100");
88 myWin.moveTo(0,0);
89 setTimeout("myWin.close()",5000);
90 }
91
92 function testDialog(){
93 var myDialog=window.showModalDialog();
94 setTimeout('myDialog.close()',5000);
95 //
96 }
97 </script>
98 </body>
99 </html>
?
轉載于:https://www.cnblogs.com/1020182600HENG/p/6076977.html
總結
以上是生活随笔為你收集整理的DHTML_____window对象方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ASP.NET Core 1.1 Pre
- 下一篇: CentOS7使用阿里云镜像安装Mong