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)




  • 相关阅读:
    区分jquery中的offset和position
    如何让搜索框的键盘显示搜索按键?
    如何设置table的border-radius?
    如何让输入框自动使用英文输入法?
    如何隐藏数字输入框的上下箭头?
    autocapticalize和autocorrect
    防止注入
    sychronized和lock和区别
    各大公司Java面试题超详细总结
    n的阶乘
  • 原文地址:https://www.cnblogs.com/tonglin0325/p/4714210.html
Copyright © 2011-2022 走看看