简体   繁体   English

用Java硬刷新页面

[英]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 我有一个问题,我先使用javascript打开一个弹出窗口,然后弹出一个窗口,在那里我对css文件进行更改,当我单击关闭时,以下javascript正在用于刷新窗口打开器页面

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

But the css remains cached in the browser, after the next refresh this only disappears. 但是,css仍保留在浏览器中,在下一次刷新后,它只会消失。 Is there a way I can hard refresh the opener page using javascript? 有没有一种方法可以使用JavaScript强制刷新打开页面?

Documentation is great: MDC - window.location 文档很棒: MDC-window.location

reload(forceget) 重新加载(强制)

Reload the document from the current URL. 从当前URL重新加载文档。 forceget is a boolean, which, when it is true, >causes the page to always be reloaded from the server. forceget是一个布尔值,当它为true时,会导致始终从服务器重新加载页面。 If it is false or not specified, the >browser may reload the page from its cache. 如果为false或未指定,> browser可能会从其缓存中重新加载页面。

Try adding a parameter to the CSS file URL: 尝试将参数添加到CSS文件URL:

mystyles.css?12345

Most browsers do a complete reload of URLs with parameters. 大多数浏览器会完全重载带有参数的URL。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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