Reputation: 41236
Is there any way to randomly access the URLs in Javascript's History
object in Safari? I'm writing an extension where I need to, on a specifically-formatted page request, capture the URL of the previous page. From what I've been able to find, the History
object definition is non-standard across browsers. Safari only seems to expose its length
property and the standard methods that actually move within the history. Where other implementations expose current
, previous
and next
properties, I can't see anything that tells me Safari does the same.
I've also tried document.referrer
, but that doesn't appear to get populated in this case.
I just need to display the previously accessed URL on a given page. Is there any other way to access that URL?
Thanks.
Upvotes: 1
Views: 1561
Reputation: 23943
You can't really do this, at least in any white-hat way. By design. You can step the user backward and forward, but you can't see the URLs.
Less scrupulous script-writers have of course taken this as a challenge. I believe the closest they've come is to dynamically write a bunch of known comparison links to the page, and then inspect them to see if they're showing in the "visited" color state. Perhaps if you're working in a closed and predictable environment (an intranet app?), with a known set of URLs, this might be a valid approach for you. Then again, in such an environment you could deal with this on the server side with session management.
Upvotes: 1