W3Max
W3Max

Reputation: 3406

Add history entry to the browser without changing the hash or any other parts of the URL

Is there a trick (with an iframe maybe...) to add an history entry to the browser without changing the hash or any other parts of the URL, while being compatible with older browsers (not older than ie8 - without pushstate)?

I know it sounds weird but here is the logic behind this question:

I'm doing a single page application and I want to get rid of modals as popups. I use the same techniques but instead of placing a div above the actual page, I would like to hide the entire page and show only the div representing the modal.

This works great, but now that the modal is taking the entire page, the user tends (and it is perfectly normal) to click on the back button to cancel the action and return to the previous page (which is hidden while the modal is displayed).

I know I could navigate to a different page (by changing the hash) but I don't want the URL to change since the destination is not a page on it's own but only a modal (it would not make sense to copy the URL of the modal and pass it to someone else or bookmarking the modal - as any normal modal inside a popup).

I would also need to be able to remove this entry in the cases where the user has completed the action (in the modal) or clicked on the cancel button.

Upvotes: 4

Views: 256

Answers (1)

W3Max
W3Max

Reputation: 3406

I found an article that explains what could be a solution (with an iframe...): from the book Ajax Design Patterns

I will give it a try soon and get you posted on the result.

Upvotes: 0

Related Questions