Take the 2-minute tour ×

I am using window.location.replace for various things on an app and passing variables in the URL (www.website.com/?clicked=2).

The problem is that it absolutely floods the history with new entries (at least in Chrome). Is there a way to just have 1 entry for the page? I thought window.location.replace was supposed to replace the entry or so I have read?

Are there any other methods out there? If you use the app legitimately for like a minute clicking things, it will take up a page of history.

share|improve this question
Take a look at History.js. It lets you modify the URL without reloading the browser window. –  Blender Sep 13 '12 at 23:38
@Blender thanks, but I downloaded and tested the demo it had, and it still produces multiple entries in Chrome. –  user1631995 Sep 13 '12 at 23:55
add comment

2 Answers

up vote 0 down vote accepted

I do not think you can do that. window.location.replace will simply change an URL and reload page. As it is a different URL - it will be added to navigation history. Suppose the only thing you can do here - download full page with ajax. Little strange usage of ajax, but it will solve your problem with multiple entries in history. With things like History.js you can control what is in browser history, but page will be loaded with ajax anyway.

share|improve this answer
I don't actually know ajax, though I know what it is used for, but I think I understand what you are saying. Basically mask the old page. I suppose there's no hope ahhh –  user1631995 Sep 13 '12 at 23:56
well... ajax is nothing hard, in general. But at the same time you may find a lot of problems with it. And in window.location there is nothing that can help you. By the way - I see no any problem with a lot of links in history. –  FAngel Sep 13 '12 at 23:59
Thanks, I don't have a problem with ajax, it's that the history.js demo in the .zip doesn't even work. I guess I'll just leave it as is and hope the user doesn't mind a page or so of entries. –  user1631995 Sep 14 '12 at 0:04
add comment

Location.replace( does not make a history entry.

share|improve this answer
add comment

Your Answer

