3

I want to load a "new" url and force a refresh on that. If I do something like this:

window.open(url,"_self");
location.reload(true);

Then the the old URL will be reloaded. If I just use "open" the cache is used.

The URL from server is the same. For example:

currentURL = "index.html#/TheOldURL";
window.open("index.html#/TheNewURL","_self");
location.reload(true);

The code would do a reload of index.html#/TheOldURL. Is there any way to force a reload of the page but with the new URL?

user3783327
  • 616
  • 8
  • 30
  • 60

2 Answers2

4

in order to force a refresh on the url, you have to mark it as a new url. this can be done by adding a unique identifier to the url. using your example:

window.open (url+"?dt="+(new Date()).getTime(),"_self");
shayuna
  • 476
  • 4
  • 8
2

You can have a handle on the new window and refresh that.

var childWindow = window.open(/* ... */);
childWindow.location.reload();

refresh child window from parent window

Community
  • 1
  • 1
Nur Bar
  • 731
  • 2
  • 8
  • 16
  • But this seems not working if I plan to use the same window. I guess my initial question can't be solved. – user3783327 Oct 21 '15 at 09:31
  • 1
    It depends, do you have access to any server side programming? actually, I think I just found a way - if you append a timestamp to the link. something like that timestamp = Date.now() window.open("index.html#/TheNewURL?v=" + timestamp,"_self"); http://stackoverflow.com/questions/11467873/how-to-append-timestamp-to-the-java-script-file-in-script-tag-url-to-avoid-cac – Nur Bar Oct 21 '15 at 14:23