473,395 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Tell is this is back page in the history

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

Nov 7 '05 #1
10 8033
pm******@uwaterloo.ca said the following on 11/7/2005 1:41 PM:
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///


You can't.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 7 '05 #2
VK
pm******@uwaterloo.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);
}

Nov 7 '05 #3
VK said the following on 11/7/2005 6:12 PM:
pm******@uwaterloo.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.


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);
}

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 7 '05 #4
VK wrote:
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.length gives exactly no indication whether there is a previous (or
next) URI in the history or not. For example, it yields 50 in my (TBE
enhanced) Firefox no matter which site in the tab's history I am visiting.

I am not surprised by that:

<http://docs.sun.com/source/816-6408-10/history.htm#1193301>
PointedEars
Nov 7 '05 #5

pm******@uwaterloo.ca wrote:
Hello,
How can I tell if there is a page to go back to in the history or
not???


Even if there were a property like 'history.currentIndex' it would
represent the entire browsing history of the current window, not just
that of the pages visited on your site.

--
S.C.

Nov 8 '05 #6
i would just like to know for the window.. i am developing a web
application (using asp .net/visual basic .net/javascript) right now and
have back/forward "buttons" (really just images linked to
history.back()) in a pop up window used for help and I want to display
a different "greyed" out image when there isn't a page to go
back/forward to.

Nov 8 '05 #7
i would just like to know for the window.. i am developing a web
application (using asp .net/visual basic .net/javascript) right now and
have back/forward "buttons" (really just images linked to
history.back()) in a pop up window used for help and I want to display
a different "greyed" out image when there isn't a page to go
back/forward to.

Nov 8 '05 #8
pm******@uwaterloo.ca said the following on 11/7/2005 9:10 PM:
i would just like to know for the window.. i am developing a web
application (using asp .net/visual basic .net/javascript) right now and
have back/forward "buttons" (really just images linked to
history.back()) in a pop up window used for help and I want to display
a different "greyed" out image when there isn't a page to go
back/forward to.


Must not be much of an app if you haven't figured that out yet. Create
your own history trail and track. Either in a cookie, on the server, or
in the page itself.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 8 '05 #9

pm******@uwaterloo.ca wrote:
i would just like to know for the window.. i am developing a web
application (using asp .net/visual basic .net/javascript) right now and
have back/forward "buttons" (really just images linked to
history.back()) in a pop up window used for help and I want to display
a different "greyed" out image when there isn't a page to go
back/forward to.


Just out of curiosity, is there any particular reason you think your
users need two sets of back/forward buttons?

-- David

Nov 8 '05 #10
VK
>> VK said the following on 11/7/2005 6:12 PM:
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
Randy Webb wrote:
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.


I do believe you as deep as I do believe in The Array - that's the
highest swear you may expect from me :-)

Sorry I was ambiguos in my post:
if (history.length) ...
check *may* tell you if browser has history.length property and if
there was *any* navigation during the current session. The latter check
may also fail easily if the previous page was the first in the session
and if you came on the current page via replace() method supported by
some browsers.
So history.length doesn't give you any idea where (by the index
position) are you now and its counter is not accurate in many
circumstances.

if (history.length) {history.go(-1);} is just additional check to avoid
some (but not all at all) situations.

Nov 8 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kim Therkelsen | last post by:
Hi! By pressing a button I am directed from one page to another. At the second page some things displayed on the first page are changed and now I want to go back to the first page again. The...
3
by: Nick Tew | last post by:
Hi, Firstly, any help would be gratefully received. Im using several iframes on a single page and would like individual 'back' and 'forward' buttons located in each of the iframes which only...
6
by: Rich | last post by:
Am just beginning to use javascript. I have some pages that can be arrived at from more than one other page. Yes, the user can use the back button but I'd like to have a back link at the bottom...
3
by: riotctrl | last post by:
Is there a way to use the history.back to display the actual url of the last page to the page ?
3
by: woodsie | last post by:
i'm looking for a back script that will work in Safari (on mac). the one below works fine in IE and netscape but not safari. <a href="#" onClick="history.go(-1)">go back</a> any help plz?
1
by: HandersonVA | last post by:
I used <input type="button" value="Back to Correct" onclick="window.history.back();"> to go back to the previous page is working, but if i use the as below instead, it does not work. what did I do...
1
by: Chris Uwins | last post by:
Hi there, i know theres a number of ways I can achieve this but want to know the best, (but still quite simple). Up until a year ago I never used Access but have designed a few databases for...
2
by: Luboą ©lapák | last post by:
Hi, I need (in one function in aspx page) return the WWW browser back to previous page. How can I do it? Thanks
2
by: sujith.bolar | last post by:
Hello I am using a <form method="post"to submit values to the processing agent. If the processing agent returns an error, I call the history.go(-1) or history.back() function to reload the page....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.