How to go back to the previous page using Javascript
well, this is how you can go back to the previous page through Javascript.
javascript:history.go(-1);
well, this is how you can go back to the previous page through Javascript.
javascript:history.go(-1);
Going back is easy enough, but what if there is nothing to go back to? I would like to be able to detect if history.go(-1) will actually do anything. If not, have a disable back button displayed.
if there’s nothin to go back to it doesnt do anything… as far as disabling the back button displayed it concerned. Try checking the length of the history object.
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.
I’d suggest u use ur own way of navigation for that. Using Sitemap objects in ASP .NET would be mighty helpful I think. Wish u all the best
Do you have any suggestions in using the “back javascript” on wordpress.com? Seems like they allow a limited number of javascripts by users on their blogs.
Thanks for dropping by. I really think WordPress wont allow that anyway bcz if they allow users to put JS on freely they can do lots of things WordPress doesnt want them to be doing like adding ads etc.