acewundabar
acewundabar

Reputation: 41

js/iframes: force iframes to reload

How can I force an iframe to reload and not load from cache?

Upvotes: 4

Views: 2020

Answers (2)

Pekka
Pekka

Reputation: 449385

To force it to reload every time, add a random GET parameter to its URL:

iframe.src = "testpage.html?reload="+Math.random();#

or as Jacob suggests, the current timestamp (eliminating the possibility of duplicates):

iframe.src = "testpage.html?reload="+(new Date()).getTime();

Upvotes: 4

Avindra Goolcharan
Avindra Goolcharan

Reputation: 4211

someIframe.src += "#forceReload";

Should work. or:

someIframe.src += "?fakeQuery";

Upvotes: 0

Related Questions