adit
adit

Reputation: 33684

how to pop URL using HTML 5 history API

I wanted to know if it's possible to have a for loop over the stack of the URL in the history API.. so basically I wanted to pop up the history URL stack until I reached URL X. How can I do that? Is it possible?

Upvotes: 3

Views: 1302

Answers (2)

Quentin
Quentin

Reputation: 944568

You can keep calling history.back() until location.href is the value you want.

This will only work if going back in the history keeps you on the same page (e.g. because you are going back through history objects that you added with pushState), otherwise your JS will stop running.

Upvotes: 2

Steven Lambert
Steven Lambert

Reputation: 5921

It's not possible. Getting any URL data from the history object would be a huge privacy concern as anyone could read your browsing history.

Upvotes: 0

Related Questions