I have a web page in which I am trying to refresh a iFrame. I'm trying to do it with something like a <input />
button and javascript. I can't seem to get the iFrame to reload without clearing the cache. Getting PHP to clear the cache would be even better.
EDIT-UPDATE
Here's the working implementation inline.
<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 of coarse the onload was soon to follow, eliminating the need for the 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>