关于 history.go()的异常捕获问题

hxa165 2011-01-11 01:36:42
try{alert("1");history.go(-5)}
catch(e)
{alert("2");
try{history.go(-4)}
catch(e){
try{history.go(-3)}
catch(e){
try{history.go(-2)}
catch(e){
try{history.back()}
catch(e){alert("3")}}}}}
异常捕获不到。。。只是弹出了1后面就没动静了。。。页面也不返回
哪个大侠给给讲讲这个的异常捕获怎么弄。或者怎么实现这个功能。
...全文
161 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainsilence 2011-01-11
  • 打赏
  • 举报
回复
服务器端记录用户的转发历史,保存在session里。
hxa165 2011-01-11
  • 打赏
  • 举报
回复
A页面 的url 有 传值情况。。 所以不能确定a的 具体url
hxa165 2011-01-11
  • 打赏
  • 举报
回复
返回上一页。
在B页面有按钮点击后刷新页面的。只是history.back() 不能完全实现。。因为不知道用户点击了几次(最多是5次)。。功能是不管用户点击了几次(0-5),只要点击返回的时候能返回到A页面
yixianggao 2011-01-11
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hxa165 的回复:]
那就是说 他不会产出错误。就没有异常来捕获了。。。这个功能该怎么实现呢[/Quote]
lz 想实现什么功能,详细说一下好不
hxa165 2011-01-11
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xming4321 的回复:]
<script language="javascript">
try{
alert("1");
istory.go("ddd");
}
catch(e)
{alert("2");
try{history.go(-4);}
catch(e){
try{history.go(-3);}
catch(e){
try{history.go(-2);}
catch(e){
try{……
[/Quote] 额 我要是能确定准备的url 就不用这么麻烦了。还有其他的方法么
hxa165 2011-01-11
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yixianggao 的回复:]
history.go()

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.

如果用户尝试跳转至起止范围之外不会产生错误。取而代之,用户……
[/Quote]那就是说 他不会产出错误。就没有异常来捕获了。。。这个功能该怎么实现呢
十一文 2011-01-11
  • 打赏
  • 举报
回复
<script language="javascript">
try{
alert("1");
istory.go("ddd");
}
catch(e)
{alert("2");
try{history.go(-4);}
catch(e){
try{history.go(-3);}
catch(e){
try{history.go(-2);}
catch(e){
try{history.back();}
catch(e){alert("3")}}}}}
</script>
看看这个地名你就明白了
yixianggao 2011-01-11
  • 打赏
  • 举报
回复
至少 ie 下 history.go() 的行为是这样儿滴!


Web 开发常用手册

DHTML 参考手册 -- 参考这里
http://download.csdn.net/source/308913

JScript 语言参考
http://download.csdn.net/source/308916

CCS 样式表中文手册
http://download.csdn.net/source/304124
yixianggao 2011-01-11
  • 打赏
  • 举报
回复
history.go()

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.

如果用户尝试跳转至起止范围之外不会产生错误。取而代之,用户将被留在当前页。

87,907

社区成员

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

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