Home  >  Article  >  Web Front-end  >  JavaScript中的History历史对象_基础知识

JavaScript中的History历史对象_基础知识

WBOY
WBOYOriginal
2016-05-16 19:06:431181browse

JavaScript中的History历史对象包含了用户已浏览的 URL 的信息,是指历史对象指浏览器的浏览历史。鉴于安全性的需要,该对象收到很多限制,现在只剩下下列属性和方法。History历史对象有length这个属性,列出历史的项数。JavaScript 所能管到的历史被限制在用浏览器的“前进”“后退”键可以去到的范围。本属性返回的是“前进”和“后退”两个按键之下包含的地址数的和。

History历史对象并有以下方法



back() 后退,跟按下“后退”键是等效的。

forward() 前进,跟按下“前进”键是等效的。

go() 用法:history.go(x);在历史的范围内去到指定的一个地址。如果 x  0,则前进 x 个地址,如果 x == 0,则刷新现在打开的网页。history.go(0) 跟 location.reload() 是等效的。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn