jimmykup jimmykup - 8 months ago 135
Javascript Question

Can I force a hard refresh on an iframe with JavaScript?

I've found many answers on Stack Overflow about how to refresh an iframe with JavaScript.

For example:

They work fine. However, if the page in the iframe has changed recently, the refresh will not show this change. Is there any way I can force a hard refresh on the designated iframe so that the new version is shown?


If the iframe is same-origin, you can force a full page reload using

iframe.contentWindow.location.reload(true);//The argument "true" will force all loaded resources, such as images, to be re-checked for expiry at the server

View an example at jsFiddle

More information at the Mozilla Developer wiki