0

My Website shows for two seconds a "Loaded!" at the start of the URL path (site.com/Loaded!/forums) without reloading the page

The problem is that the browser is currently saving the "fake" link in the history: History

Is there any way to prevent the browser to save this link?

Lorenzo Lapucci
  • 129
  • 4
  • 12

1 Answers1

2

Your page has code:

 if (_timer) clearInterval(_timer);
    window.history.pushState('', 'MineLight', "Loaded!/" + Url);
    setTimeout(Back, 2000);

window.history.pushState:

HTML5 introduced the history.pushState() and history.replaceState() methods, which allow you to add and modify history entries, respectively. These methods work in conjunction with the window.onpopstate event.

You must delete it.

Adding and modifying history entries

UserName
  • 895
  • 7
  • 17
  • So if I use another method to change the url it could work? – Lorenzo Lapucci May 26 '16 at 19:16
  • @HAlexTM, I do not understand what you want. You want to record correct address in history browser. Why do you need to change URL? If you remove this code will be recorded real address of the page in history page. – UserName May 26 '16 at 19:19
  • I'd like to show a "Loaded!" at the begin of the url's path for two seconds without saving it in history – Lorenzo Lapucci May 26 '16 at 19:21
  • 1
    @HAlexTM, you can try use replaceState(); Quote"history.replaceState() operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one. Note that this doesn't prevent the creation of a new entry in the global browser history." – UserName May 26 '16 at 19:24
  • This could be the solution, let me test it :) – Lorenzo Lapucci May 26 '16 at 19:25
  • 1
    @HAlexTM - Honestly? Don't bother with that. Users don't care, or won't even notice, if the URL says 'Loaded!' for 2 seconds and then disappears. All this while you could be working on other aspects of the site that actually matter. – mferly May 26 '16 at 19:26
  • 1
    @HAlexTM. +1 to Marcus. But.. If you very want, can better visualize it in the form of inscriptions or unobtrusive window to the page – UserName May 26 '16 at 19:28
  • @UserName it doesn't work, anyway Marcus you're right, maybe I should bother with something else.. – Lorenzo Lapucci May 26 '16 at 19:29
  • If you wanted to, though, you could look into using a `#` hash in the URL. Does not affect history: `window.location.hash = 'Loaded!'` creates a URL like: `site.com/#Loaded!` then you can just figure a way (easily) to remove the hash after 2 seconds or whatever – mferly May 26 '16 at 19:41
  • @Marcus I tried, and their is no way to remove the '#' – Lorenzo Lapucci May 27 '16 at 13:12
  • @HAlexTM, here are examples. They are workers. [history.replaceState() example?](http://stackoverflow.com/questions/12832317/history-replacestate-example) – UserName May 27 '16 at 13:22