JavaScript————BOM

来源:互联网 发布:淘宝打折工具有什么用 编辑:程序博客网 时间:2024/05/20 13:38
1.navigator对象:获取客户机信息
2.screen对象:获取屏幕信息
3.location对象:请求URL地址
    ——href
       (1)得到当前请求地址
        *(2)设置URL地址
              用法:一个页面上,在按钮上绑定一个
          事件,当我点击这个按钮,页面可以跳
          转到另一个页面。

          代码:

<html> <head>  <meta charset="UTF-8">  <title>Document</title> </head> <body>  <input type="button" value="主页" onclick="goHome()"/> </body>  <script tyoe="text/javascript">function goHome(){var p = confirm("回主页?");if(p==true)location.href="Noname2.html";} </script> </html>


4.history对象
    ——back():上一页面
    ——forword():下一页面
    ——go():当前相对的距离
5.window对象
    ——alert():弹出一个警示窗口
    ——confirm():确认框
    ——prompt():对话框(少用)
        prompt("显示内容","输入框里的默认值");
    ——open():打开一个新窗口
        open("URL","name(可为空)","窗口特征(宽,高等)");
    ——close():关闭窗口
    *——setInterval("js代码",毫秒数): 循环执行
    ——clearInterval():清除setInterval

    代码:

<html> <head>  <meta charset="UTF-8">  <title>Document</title> </head> <body>    <input type="button" value="取消" onclick="clear()"/> </body>  <script tyoe="text/javascript">  window.setInterval(alert("lala"),1500);var id=function clear(){clearInterva(id);} </script> </html>


    *——setTimeout("js代码",毫秒数):执行一次
    ——clearTimeout():清除setTimeout
0 0