JS之BOM
1.window
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Bom对象;因为需要跟浏览器对话。</title> 6 7 <script type="text/javascript"> 8 /*bom对象最重要的就是与浏览器对话*/ 9 //window对象 10 //----alert----confirm--prompt------- 11 window.alert("你好"); 12 var res=window.confirm("内容保存?"); 13 var res=window.prompt("写入框"); 14 alert(res); 15 //setInterval-----cleanInterval 16 function begin(){ 17 var Stime=new Date().toLocaleString(); 18 var begin=document.getElementById("text"); 19 begin.value=Stime 20 } 21 var ID; 22 function setI(){ 23 if(ID==undefined){ 24 ID=window.setInterval(begin,1000); 25 } 26 } 27 function end(){ 28 window.clearInterval(ID); 29 ID=undefined; 30 } 31 </script> 32 </head> 33 <body> 34 <input type="text" style="width:200" id="text"/> 35 <input type="button" value="begin" id="begin" onclick="setI()" /> 36 <input type="button" value="end" id="end" onclick="end()" /> 37 </body> 38 </html>