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)




  • 相关阅读:
    深入了解接口
    深入.NET平台C#编程 测试题分析
    如何设计高级的数据库
    数据库查询的基础技巧
    回顾Spring MVC_01_概述_入门案例
    初学My Batis之入门
    Spring MVC之视图解析器和URL-Pattern的配置方案
    SpringMVC之入门
    WebService入门
    Spring之实现任务调度
  • 原文地址:https://www.cnblogs.com/tonglin0325/p/4714210.html
Copyright © 2011-2022 走看看