pm******@uwater loo.ca wrote:
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 {
}
// 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);
}