/    Sign up×
Community /Pin to ProfileBookmark

history.previous

Hi, all!

In my script, I have the value history.previous. It should work, but in Safari it returns undefined and in Mozilla I got the javascript error “Permission denied to get the value history.previous”. What should I do? Is there a property that will work better? How would I use http referer?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@themartyJul 04.2006 — i find it hard to believe this information cannot be found with the search or google.
Copy linkTweet thisAlerts:
@KravvitzJul 04.2006 — Use document.referrer.
Copy linkTweet thisAlerts:
@felgallJul 04.2006 — You can't read what is held in the history object, you can only transfer to the page it refers to.

You can't rely on document.referrer either as some visitors will have disabled it.
Copy linkTweet thisAlerts:
@shane_carrauthorJul 04.2006 — i find it hard to believe this information cannot be found with the search or google.[/QUOTE]

I've been searching for a while, but it only tells me how to use it, and not how to troubleshoot it. And, I do not have very good search engine optimization skills.



You can't read what is held in the history object, you can only transfer to the page it refers to.[/QUOTE]

Then why does it even have the property?



Use document.referrer.[/QUOTE]

Thanks! That seems to do about what I want to do!



You can't rely on document.referrer either as some visitors will have disabled it.[/QUOTE]

Oh, well. Nothing can be absolutely perfect. However, I'm still open to suggestions.




Thanks everyone!
Copy linkTweet thisAlerts:
@felgallJul 04.2006 — The history object is there to allow you to transfer to a different page that your visitor has already viewed.

[b]location.href = history.back();[/b] // go to previous page equivalent to browser back button

[b]location.href = history.forward();[/b] // and forward again to the page that you went back from equivalent to browser forward button

[b]location.href = history.go(-2);[/b] // go back two pages instead of one

you can use whatever number you like with go() to jump back or forward by multiple pages at once provided that there are enough entries in the history to go that far.

The best way to keep track of where someone came from on your own site is to pass the information between pages in your own custom field either by appending it to the end of addresses, in cookies, or by usig a session.
Copy linkTweet thisAlerts:
@themartyJul 04.2006 — you can use whatever number you like with go() to jump back or forward by multiple pages at once provided that there are enough entries in the history to go that far.[/quote]this is incompatible with the browser's back-button though.

only history.back() acts exactly the same

The best way to keep track of where someone came from on your own site is to pass the information between pages in your own custom field either by appending it to the end of addresses, [b]in cookies[/b], or by usig a session.[/quote]the chance that setting a cookie fails is a lot bigger than the chance that javascript fails, so i wouldn't call that better
×

Success!

Help @shane_carr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...