BOM(Broswer Object Model)

方法:
    框窗
      1.警告框
      window.alert("msg");
      2.确认框
      window.confirm("msg");
      3.询问框
      window.prompt("msg","defaulvalue")

   var result = window.prompt("请输入密码","例如:132456")
    页面
      1.打开一个窗口
      window.open()
      2.在子窗口中使用,表示父窗口的window对象
      window.opener
      3.关闭当前窗口
      window.close()
定时任务
      1.定时任务
      var taskid = window.setTimeout(function,ms);
      2.间隔执行任务
      var taskid = window.setInteval(function,ms);
      3.清除定时任务
      window.clearTimeout(taskid);
      4.清除间隔执行任务
      window.clearInteval(taskid);

<script type="application/javascript">

    function confirmBuy(){
var flag = window.confirm("您确定要付款吗?")
if(flag){
//付款成功
window.open("success.html",'success',"height=300,width=500,top=50,left=50,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no") }
} </script>
<body>
<h1>购物车</h1>
<hr/>
<ul>
<li>商品1</li>
<li>商品2</li>
<li>商品3</li>
</ul>
<button onclick="confirmBuy();">确认付款</button>
</body>
<script type="application/javascript">

  /*  window.onload = function(){
window.setTimeout(closeSelf,1000);
} function closeSelf(){
var secval = document.getElementById("sec").innerHTML
var secint = parseInt(secval);
document.getElementById("sec").innerHTML = --secint;
if(secint == 0){
window.close();
}
window.setTimeout(closeSelf,1000)
}*/
var taskid = 0; window.onload = function(){
taskid = window.setInterval(closeSelf,1000)
}
function closeSelf(){
var secval = document.getElementById("sec").innerHTML;
var secint = parseInt(secval)
document.getElementById("sec").innerHTML = --secint;
if(secint == 0){
window.close();
}
} function stopTask(){
window.clearInterval(taskid);
}
function goonTask(){
taskid = window.setInterval(closeSelf,1000);
console.log(taskid)
} </script>
<body>

付款成功,页面将在<span id="sec">10</span>s后关闭。
<button onclick="stopTask()">稍等,待会我会自己关闭</button>
<button onclick="goonTask()">继续读秒,关闭窗口</button> </body>
 
05-19 19:23