简体   繁体   中英

Hard refreshing a page with Javascript

I have a question, I'm opening a pop-up window using javascript then a window pops-up, there I make changes to the css file, when I click on close the following javascript is being used to refresh the window opener page

window.opener.location.reload();
window.close();

But the css remains cached in the browser, after the next refresh this only disappears. Is there a way I can hard refresh the opener page using javascript?

Documentation is great: MDC - window.location

reload(forceget)

Reload the document from the current URL. forceget is a boolean, which, when it is true, >causes the page to always be reloaded from the server. If it is false or not specified, the >browser may reload the page from its cache.

Try adding a parameter to the CSS file URL:

mystyles.css?12345

Most browsers do a complete reload of URLs with parameters.

But make sure, you remove that, when your site goes into production mode!

Try the following:

window.opener.location.href=window.opener.location;
window.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM