zoukankan      html  css  js  c++  java
  • js-window对象

    BOM浏览器对象模型:是规范浏览器对js语言的支持(js调用浏览器本身的功能)
    BOM的具体实现是window对象
    window对象使用学习
    1.window对象不用new,直接进行使用即可,类似Math的使用方式,window关键字可以省略不写
    2.框体方法
      alert:警告框 提示一个警告信息,没有返回值
      confirm:确认框 提示用户选择一项操作(确认、取消)
      点击确认 返回 true
      点击取消 返回 false
      prompt:提示框,提示某个信息的录入或者说收集
      点击确认,返回当前用户输入的数据,默认值返回空字符串。
      点击取消,返回null
    3.定时和间隔执行方法
      setTimeout:指定的时间执行的函数
      参数1:函数对象
      参数2:时间,单位毫秒
      返回值:返回当前定时器的id
      setInterval:设间隔指定时间执行指定的函数
      参数1:函数对象
      参数2:时间,单位毫秒
      返回值:返回当前间隔器的id
      clearTimeout:用来停止指定的定时器
      参数1:定时器的id
      clearInterval:用来停止指定的时隔器
      参数:间隔器的id
    4.子窗口方法

    <script type="text/javascript">
    //框体方法
    //警告框
    function testAert(){
      window.alert("我是警告框");
    }
    //确认框
    function testConfirm(){
      window.confirm("你确定要删除吗");
    }
    //提示框
    function testPrompt(){
      window.prompt("请输入昵称:");
    }
    var id;
    var ids;
    //定时执行
    function testSetTimeout(){
      id=window.setTimeout(function(){
      alert("我是定时执行");
      },3000);
    }
    //间隔执行
    function testSetInterval(){
      ids=window.setInterval(function(){
      alert("我是间隔执行");
      },2000);
    }
    //停止当前的定时
    function testClearTimeout(){
      window.clearTimeout(idi);
    }
    function testClearInterval(){
      window.clearInterval(ids);
    }
    </script>
    </head>
    <body>
    <h3>window对象学习</h3>
    <hr />
    <input type="button" name="" id="" value="测试警告框" onclick="testAert()"/>
    <input type="button" name="" id="" value="测试确认框" onclick="testConfirm()"/>
    <input type="button" name="" id="" value="测试提示框" onclick="testPrompt()"/>
    <hr />
    <input type="button" name="" id="" value="测试setTimeout框" onclick="testSetTimeout()"/>
    <input type="button" name="" id="" value="测试setInterval框" onclick="testSetInterval()"/>
    <input type="button" name="" id="" value="测试clearTimeout框" onclick="testClearTimeout()"/>
    <input type="button" name="" id="" value="测试clearInterval框" onclick="testClearInterval()"/>
    </body>

  • 相关阅读:
    supervisor(一)基础篇
    linux添加开机自启动脚本示例详解
    suse 不能远程登录
    LintCode,hihoCoder,LeetCode有什么区别?
    windows 下安装nodejs 要怎么设置环境变量
    Java 集合:HashSet 与 ArrayList
    Java ArrayList、Vector和LinkedList等的差别与用法(转)
    一行代码实现java list去重
    25 highest paying companies: Which tech co outranks Google, Facebook and Microsoft?
    Chart: Who pays the most in Seattle for software engineers
  • 原文地址:https://www.cnblogs.com/qhcyp/p/10629341.html
Copyright © 2011-2022 走看看