zoukankan      html  css  js  c++  java
  • JavaScript学习笔记——BOM_window子对象_History、Location、Screnn对象

    javascript-History、Location、Screnn对象实例讲解

    一、history对象
    包含浏览器访问过的url

      1.属性
      length 返回浏览器历史记录的数量

    alert(history.length)

      2.方法

      back() 后退
      forward() 前进
      go(number) 如果参数是正数,那么就是前进相应的数目,如果是负数那么反之,如果是0那么就是刷新

      window.onload=function  () {
         var one=document.getElementById("one");
         one.onclick=function  () {
            //history.forward()
            history.go(3)
         }
      }

     

    二、location对象 包含有当前url的相关信息

      1.属性
      href 设置或 返回完整的url

    alert(location.href);

      search 返回url?后面的查询部分

    alert(location.href="location2.html?1234")
    alert(location.search)

      2.方法
      assign() 加载新的文档

    location.assign("location2.html");

      reload(boolean) 重新加载文档, 当参数是true,任何时候都会重新加载,false的时候,只有在文档改变的时候才会加载,否则直接读取内存当中的。

    location.reload()

      replace() 用新的文档代替当前的文档 (没有历史记录)

    location.replace("location2.html")

    三、screen对象
    记录了客户端显示屏的信息

      属性:
      availHeight 返回显示屏幕的高度 (除 Windows 任务栏之外)。
      availWidth 返回显示屏幕的宽度 (除 Windows 任务栏之外)。

      height 返回显示屏幕的高度。
      width 返回显示屏幕的宽度。

      document.write(screen.availHeight)
      document.write("<br/>")
      document.write(screen.height)
       document.write("<hr/>")
      document.write(screen.availWidth)
       document.write("<br/>")
      document.write(screen.width)




  • 相关阅读:
    Android10_内容提供者_内容观察者_标题栏
    Android08_广播接受者_服务
    Android09_远程服务_系统服务_aidl
    Android07_多界面_Activity生命周期
    Android06_getpost提交_文件上传_多线程下载
    Android_handler_网络请求_img框架
    Android开发04
    java 正则表达式验证邮箱
    postman 基本用法
    java 微信申请退款的开发
  • 原文地址:https://www.cnblogs.com/tonglin0325/p/4714210.html
Copyright © 2011-2022 走看看