Javascript: Refresh Parent Page Without Entirely Reloading

After a user has logged in via a fancybox (javascript) popup I wish to reload the parent page so they can access the logged in features.

Currently I am doing this with:

<a href="javascript:window.top.location.reload(true)" class="continue">Continue</a>

This works great, but the only issue is that it completely reloads the entire page: redownloads all the css & javascipt, etc.

All I want to do is reload the page normally, not a full refresh. How can I achieve this?

(I do not know the exact URL because the login can be done from any page via the fancybox, so I can't hardcode the URL.)

2 Answers

Another way of reloading the page i have seen in the facebook graph api is the following:

window.location = window.location

or in your case:

window.top.location = window.top.location

This solution reloads the page without trying to resend a POST request. Might be useful. for more information look at the following SO question.

4

Use:

location.replace(location.href.split('#')[0]);

The split on hash is required, otherwise an url with a hash will not be refreshed.

If you want to keep the previous load in browser history, use assign instead of replace.

href is not currently supported by Opera, according to MDN.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest