问题描述
您好,
如何判断历史记录中是否有页面或
不是???与前进相同???说一些像///
if(有一页要回去){
//做点什么
}其他{
}
和simularly
if(还有一页要去转发){
//别的东西
}否则{
}
谢谢,Pam
Hello,
How can I tell if there is a page to go back to in the history or
not??? Same with forward??? say something like///
if (there is a page to go back to ) {
// DO something
}else {
}
and simularly
if(there is a page to go forward to ) {
//DO something else
}else {
}
Thanks,Pam
推荐答案
你不能。
-
兰迪
comp.lang.javascript常见问题 - &新闻组每周
Javascript最佳实践 -
You can''t.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
//返回:
history.go(-1);
// history.back()方法也可以,但
//它有时会在某些浏览器上被阻止
//出于某些神秘的安全原因。 br />
//前进:
history.go(1);
// history.forward()方法可以也是,但是
//它有时会在某些浏览器上被屏蔽
//出于某些神秘的安全原因。
如果没有页面可以返回或转发,用户将保留在当前页面上,
不会发生错误,所以不用担心。
历史.length会让你知道用户在来到这里之前导航了多少
。只有一些想法因为这个计数器有一些
限制太多,无法在这里描述它们。但如果你真的想要
- 那么你可以:
如果(history.length){//至少有一页在我之前
history.go(-1);
}
// To go back:
history.go(-1);
// history.back() method is OK too, but
// it''s sometimes blocked on some browsers
// for some misterious security reasons.
// To go forward:
history.go(1);
// history.forward() method is OK too, but
// it''s sometimes blocked on some browsers
// for some misterious security reasons.
If no page to go back or forward, user will stay on the current page,
no error will happen, so don''t worry.
history.length will give you some idea about how much did user navigate
before she came here. Only "some idea" because this counter has some
limitations too numerous to describe them here. But if you really want
to - then you can:
if (history.length) { // at least one page before mine
history.go(-1);
}
仅当有页面要返回时来,你没有可靠的方法来确定这一点。
//前进:
history.go(1);
/ / history.forward()方法也可以,但是
//它有时会在某些浏览器上被阻止
//出于某些神秘的安全原因。
只有当有一个页面要前进,而你没有可靠的方式
才能确定。
如果没有页面可以返回或转发,用户将保留在当前页面上,
不会发生错误,所以别担心。
但他们会有一个断开的链接,表示程序员的
部分无能为力。
history.length将给出在她来到这里之前,你知道用户导航了多少。只有一些想法因为这个计数器有一些限制,无法在这里描述它们。但如果你真的想要
- 那么你可以:
不,你不能,你认为你可以。
如果( history.length){//我前面至少有一页
不,这意味着历史有一段长度。
开放page1.html,导航到page2.html,按后退按钮返回
返回page1.html。检查history.length。然后,阅读我的回复和
相信它。
history.go(-1);
}
Only if there is a page to go back to, and you have no reliable way to
determine that.
// To go forward:
history.go(1);
// history.forward() method is OK too, but
// it''s sometimes blocked on some browsers
// for some misterious security reasons.
Only if there is a page to go forward to, and you have no reliable way
to determine that.
If no page to go back or forward, user will stay on the current page,
no error will happen, so don''t worry.
But they will have a broken link which indicates incompetence on the
part of the programmer.
history.length will give you some idea about how much did user navigate
before she came here. Only "some idea" because this counter has some
limitations too numerous to describe them here. But if you really want
to - then you can:
No you can''t, you just think you can.
if (history.length) { // at least one page before mine
No, it means there is a length to the history.
Open page1.html, navigate to page2.html, press the back button to go
back to page1.html. Check history.length. Then, read my response and
believe it.
history.go(-1);
}
-
兰迪
comp.lang.javascript常见问题 - &新闻组每周
Javascript最佳实践 -
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
这篇关于告诉这是历史记录中的后页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!