66
rated 0 times
[
68]
[
2]
/ answers: 1 / hits: 23037
/ 12 Years ago, mon, august 27, 2012, 12:00:00
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>
More From » php