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)




  • 相关阅读:
    Struts2的原理,配置和使用
    tomcat启动异常之----A child container failed during start
    Oracle两表关联更新其中一张表的数据
    jsp隐藏字符串中间部分信息,只显示前后字段
    浏览器会缓存js文件
    tomcat启动项目很快,且不报错,访问报404,项目实际上没起来,起的是空tomcat
    jd-eclipse插件的安装
    Junit4使用总结
    json中dump()与dumps()里的参数解释
    python时间函数和常用格式化
  • 原文地址:https://www.cnblogs.com/tonglin0325/p/4714210.html
Copyright © 2011-2022 走看看