I have a webpage where I am trying to update an iFrame. I am trying to do this with a button <input />and javascript. I cannot force the iFrame to reboot without clearing the cache. Getting PHP to clear the cache would be even better.
EDIT-UPDATE
Here's a working inline implementation.
<input type="button" onClick="javascript: var iFrame = document.getElementById('compilePreview'); iFrame.src = '<? echo ($myFile); ?>?random=' + (new Date()).getTime() + Math.floor(Math.random() * 1000000);" value="Reload Preview" />
<iframe id="compilePreview" src="<? echo ($myFile); ?>" width="940"></iframe>
And the coarse download was soon consistent, eliminating the need for a button.
<script>
window.onload=refreshIframe;
function refreshIframe(){
var iFrame = document.getElementById('compilePreview');
iFrame.src = '<? echo ($myFile); ?>?random=' + (new Date()).getTime() + Math.floor(Math.random() * 1000000);
}
</script>
source
share