如何判断 history.go(-1) 有效

bibiye 2004-09-17 03:53:18
请教一下JS:
如何判断 history.go(-1) 有效
即能够后退时,
就出现后退按钮,
如果不能后退时,
就出现关闭按钮。
谢谢!
...全文
293 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingchang2000 2004-09-24
  • 打赏
  • 举报
回复
history这个判断我就不知道了,你刚才的代码这么写看看:
<script>
if(history.length > 1){

document.writeln("<table width=\"92%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
document.writeln("<tr>");
document.writeln("<td>有历史记录</td>");
document.writeln("</tr>");
document.writeln("</table>");
}
else{
document.writeln("<table width=\"92%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
document.writeln("<tr>");
document.writeln("<td>无</td>");
document.writeln("</tr>");
document.writeln("<tr> ");
document.writeln("</table>");
}
</script>
BubbleInDiamond 2004-09-24
  • 打赏
  • 举报
回复
呕吐中……

语法错误不说了,就是history.length>1也不能说明可以后退啊,是可以前进怎么办?
根本就没有必要判断,不可以后退它自然不会后退
webmm 2004-09-24
  • 打赏
  • 举报
回复
有没有搞错,这怎么可能不出错呢~~~
<script>
if(history.length > 1){
</script>

...晕...

不过这个问题我也不会,嘻..
bibiye 2004-09-17
  • 打赏
  • 举报
回复
<script>
if(history.length > 1){
</script>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>有历史记录</td>
</tr>
</table>
<script>
}
else{
</script>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>无</td>
</tr>
<tr>
</table>
<script>
}
</script>

上面的这段怎么会脚本出错提示?
难道不能用JS和html混合的加条件判断吗?
bibiye 2004-09-17
  • 打赏
  • 举报
回复
呵,刚想删除,有人来UP了,看来分数不给都不行了
postfix2 2004-09-17
  • 打赏
  • 举报
回复
up

87,904

社区成员

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

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