紧急求助!!js里的history方法属性怎么使用?请详尽一点!!解决就给分,在线等待!!

wzm971505 2002-08-04 01:03:17
js里的history方法属性怎么使用!
谢谢!!
...全文
244 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
太古盟约 2002-08-05
  • 打赏
  • 举报
回复
1.Attributes/Properties

Syntax

[ iLength = ] history.length
Possible Values

iLength Integer that receives the number of elements.

The property is read-only. The property has no default value.

Standards Information

There is no public standard that applies to this property.


2.Methods
back: Loads a previous URL from the History list.
forward: Loads the next URL from the History list.
go: Loads a URL from the History list.

Syntax

history.back( [iDistance])
Parameters

iDistance Optional. Integer that specifies the number of URLs to go back. If no value is provided, the previous URL is loaded.

Return Value

No return value.

Remarks

This method performs the same action as a user clicking the Back button in the browser.

The back method works the same as history.go(-1).

An error does not occur if the user tries to go beyond the beginning of the history. Instead, the user remains at the current page.

Standards Information

There is no public standard that applies to this method.


Syntax

history.forward()
Return Value

No return value.

Remarks

This method performs the same action as when a user clicks the Forward button in the browser. Calling the forward method works the same as calling the go method with a parameter of 1. An error does not occur if the user tries to go beyond the end of the history. Instead, the user remains at the current page.

Standards Information

There is no public standard that applies to this method.


Syntax

history.go(vLocation)
Parameters

vLocation Required. Variant that specifies an integer or a string. An integer indicates the relative position of a URL in the History list. A string indicates an exact URL in the History list.

Return Value

No return value.

Remarks

An error does not occur if the user tries to go beyond the beginning or end of the history. Instead, the user remains at the current page.

Standards Information

There is no public standard that applies to this method.
Reve 2002-08-04
  • 打赏
  • 举报
回复
histroy.length: readonly

If you are interested in it, you will find some fun in testing this:

JavaScript:{var str=window.location;histroy.go(-history.length);window.location.replace(str);}

you can also change str to something else;
redv 2002-08-04
  • 打赏
  • 举报
回复
window.history.back()
window.history.forward()
window.history.go()
window.history.length

eg:
window.history.go(-1)==window.history.back()
window.history.go(1)==window.history.forward()
window.history.go(-2)
wjmmml 2002-08-04
  • 打赏
  • 举报
回复
你把history.back()换成上面兄弟说的你想用的属性就可以了。
wjmmml 2002-08-04
  • 打赏
  • 举报
回复
给你个例子吧,
<input type=submit name="press" value="数据错误请返回" onclick="javascript:history.back()" >
wzm971505 2002-08-04
  • 打赏
  • 举报
回复
好像不行:(
能不能说详细一点?谢谢!
saucer 2002-08-04
  • 打赏
  • 举报
回复
method 1: use location.replace to load all the pages in 一个会话

method 2: close the window and open a new one
wzm971505 2002-08-04
  • 打赏
  • 举报
回复
如果我在一个会话结束时,我想把在这期间访问过的历史记录都去掉该怎么办?
saucer 2002-08-04
  • 打赏
  • 举报
回复
from
http://www.webdevelopersjournal.com/articles/dhtml3/dhtml3.html

The history object

When you are surfing the net, you often use the back and forward buttons to go back to a page you have already visited. The history object allows us to travel forwards and backwards in script.

The use of the history object is straightforward.

history.back();

sends us back one page

history.forward();

sends us forward one page

We can also use

history.go(n);

which sends us forward n pages (n>0), or back n pages (n<0).

history.length retrieves the number of elements in the History list.

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧