JavaScript第六天笔记05——history对象(了解)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button  onclick="history.go(-1)">history</button>
    <!-- 跳转页面 -->
    <button onclick="location.assign('https://hao.360.com/')">assign</button>
    <!-- 替换页面 -->
    <button onclick="location.replace('https://hao.360.com/')">replace</button>
    <!-- 跟F5更能一样,重新加载当前页 -->
    <button onclick="location.reload()">reload</button>


    <script>
        console.log(location.href)
        console.log(navigator.appName)
        console.log(screen.width)
        console.log(screen.height)
    </script>
</body>
</html>

一、history:用户访问过的站点的列表

属性:length

方法:go()、back()、forward()

只对已经访问过的页面有效

history.go(-3);//向后返回三个访问过的页面

histroy.go(3);//向前返回三个访问过的页面

back();//与history.go(-1);功能相同

forward();//与history.go(1);功能相同

二、location: 载入窗口的URL

location

属性

说明

hash

指定浏览器到一个位于文档中的anchor位置(#之后)

host

描述一个url的主机名和端口

hostname

url的主机名

href

一个指定对象的整个url字符串

pathname

url的路径名部分由于服务器root(根)卷相关的目录结构组成

port

端口号

protocol

包括协议名,后面跟着:

location

方法

说明

assign("url")

把一个新的url赋值给location对象,页面跳转

reload()

重新加载当前页

replace("url")

通过加载 URL 指定的文档来替换当前文档

三、navigator:提供用户使用的浏览器及操作系统等信息 

navigator

属性

说明

appCodeName

浏览器代码名

appName

浏览器名称

appVersion

浏览器版本

mimeTypes

MIME类型(navigator.mimeTypes[n].type)

platform

浏览器操作系统

browserLanguage

浏览器使用的语言

userAgent

浏览器用户代理(用户浏览器Header头信息)

四、screen:获取用户屏幕信息

screen

属性

说明

width

返回屏幕宽度(像素数)

height

返回屏幕高度

availWidth

返回屏幕的可用宽度(除去一些不自动隐藏的类似任务栏的东西所占用的宽度

availHeight

返回屏幕的可用高度

colorDepth

返回当前颜色设置所用的位数,-1:黑白;8:256色;16:增强色;24/32:真彩色

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值