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?

2
  • You are going to an anchor of the same page? Then of course it will stay at the same page. Commented Oct 19, 2015 at 14:10
  • Yes, but is there a way to force a reload (with the new URL)? Commented Oct 19, 2015 at 14:13

2 Answers 2

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");
Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

But this seems not working if I plan to use the same window. I guess my initial question can't be solved.
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"); stackoverflow.com/questions/11467873/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.